|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61862 mb_convert+htmlspecialchars returns nothing.
Submitted: 2012-04-27 02:32 UTC Modified: 2012-04-27 02:48 UTC
From: jeniffer at tormail dot net Assigned:
Status: Not a bug Package: mbstring related
PHP Version: 5.4.1 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: jeniffer at tormail dot net
New email:
PHP Version: OS:


 [2012-04-27 02:32 UTC] jeniffer at tormail dot net
In PHP 5.3.x, I can get expect result.
But in PHP 5.4.x, this returns nothing. Why?

Test script:
echo $converttext;

Expected result:
こんにちは世界 (in SJIS)

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-27 02:48 UTC]
-Status: Open +Status: Not a bug
 [2012-04-27 02:48 UTC]
This was actually a bug in 5.3. 5.3, unless you specified differently would just 
assume iso-8859-1 and since every single-byte sequence is a valid char in 8859-
1, as long as it didn't see any bytes matching any special html chars, it would 
pass them right through in this case. So it wasn't actually escaping anything 
unless you got lucky and your charset was compatible with 8859-1 for those 

This function now assumes UTF-8 if you don't specify differently and if it sees 
something that isn't UTF-8 it returns nothing. Since this is a security-related 
function, we can't just pass things through we don't understand. So in your case 
you want to pass 'SJIS' as the 3rd arg to htmlspecialchars() there, or you can 
pass '' and it will use the script encoding in zend_multibyte mode.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 19:01:30 2024 UTC