|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49861 htmlspecialchars() returns incorrect results for Unicode characters outside BMP
Submitted: 2009-10-13 09:00 UTC Modified: 2009-10-13 09:07 UTC
From: Assigned:
Status: Closed Package: Strings related
PHP Version: 5.3.0 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
2 + 9 = ?
Subscribe to this entry?

 [2009-10-13 09:00 UTC]
htmlspecialchars() / htmlentities() returns incorrect results when an 
Unicode character whose codepoint is outside the range of BMP.

Confirmed with 5.3.0, 5.3SVN.

Reproduce code:
// U+1003C
var_dump(bin2hex(htmlspecialchars("\xf0\x90\x80\xbc", ENT_QUOTES, 'UTF-8'));

Expected result:
string(8) "f09080bc"

Actual result:
string(8) "266c743b"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-13 09:07 UTC]
Just a reminder: this was already fixed along with bug #49785 in SVN.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Oct 02 22:01:25 2023 UTC