php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22335 htmlspecialchars() encodes foriegn chars too!
Submitted: 2003-02-20 13:00 UTC Modified: 2003-02-22 14:27 UTC
From: caleb_ownz at yahoo dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.0 OS: Windows
Private report: No CVE-ID: None
 [2003-02-20 13:00 UTC] caleb_ownz at yahoo dot com
Hello,

The htmlspecialchars() function should only convert SPECIAL chars such as '&' '"' ''' '<' '>'. (at least this is what the documentation says)

But this function also seems to convert foriegn language (non-english) chars too which is what htmlentities() basically does.

I have tested this on Russian and Hebrew!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-20 17:25 UTC] iliaa@php.net
Could you please supply a simple string with which the problem occures.
 [2003-02-21 06:02 UTC] caleb_ownz at yahoo dot com
hmm after checking some more research i noticed that this happens only when the browser encoding != language you are writing.

So if you write in hebrew when the browser is set to encode Western European you will get something similar to this: "&#1506;&#1489;&#1512;&#1497;&#1514;" although i did solve all these problems by calling html_entities_decode() but still.. why should htmlspecialchars() encode anything but the SPECIAL chars, and not language chars..

????
becomes
&#1513;&#1500;&#1493;&#1501;
 [2003-02-22 14:26 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Works fine here, the error you are seeing sounds like a result of COPY/PASTE operation from another Win32 application. Win32 has a nasty tendency to automatically encode special characters into their HTML enteties.
The example below should demonstrate that htmlspecialchars()  works correctly.
<?php
var_dump(htmlspecialchars("????"));
?>
 [2003-02-22 14:27 UTC] iliaa@php.net
set proper status.
 [2004-05-05 01:55 UTC] mano at cvr dot hu
Hi
Yes, I also recognized this problem with the hungarian chars!
I hope that I'll find the solutions around here...

.mano
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 06:01:29 2024 UTC