|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: caleb_ownz at yahoo dot com
New email:
PHP Version: OS:


 [2003-02-20 13:00 UTC] caleb_ownz at yahoo dot com

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!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-20 17:25 UTC]
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..

 [2003-02-22 14:26 UTC]
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 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.
 [2003-02-22 14:27 UTC]
set proper status.
 [2004-05-05 01:55 UTC] mano at cvr dot hu
Yes, I also recognized this problem with the hungarian chars!
I hope that I'll find the solutions around here...

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 20:03:39 2023 UTC