php.net |  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
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:
MUST BE VALID
Solve the problem:
42 - 6 = ?
Subscribe to this entry?

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

Test script:
---------------
<?php
$converttext="こんにちは世界";
$converttext=mb_convert_encoding($converttext,"SJIS","auto");
$converttext=htmlspecialchars($converttext,ENT_QUOTES);
echo $converttext;
?>

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

Actual result:
--------------
(nothing)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-27 02:48 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2012-04-27 02:48 UTC] rasmus@php.net
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 
chars. 

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: Fri Apr 19 19:01:28 2024 UTC