|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-05-09 10:42 UTC] yyb8 at vip dot qq dot com
Description: ------------ htmlentities and htmlspecialchars do not work with chinese! $str='<a href="test.html">测试页面</a>'; echo htmlentities($str); print nothing. it is a bug? Test script: --------------- $str='<a href="test.html">测试页面</a>'; echo htmlentities($str); PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 17:00:01 2025 UTC |
Having the same problem with Windows-1250 chars: <?php echo PHP_VERSION . '<br />' . PHP_EOL; echo 'Testing: ' . htmlentities('ščćžđ ŠČĆŽĐ') . '<br />' . PHP_EOL; echo 'Testing: ' . htmlspecialchars('ščćžđ ŠČĆŽĐ') . '<br />' . PHP_EOL; echo 'Testing: ' . substr('ščćžđ ŠČĆŽĐ', 0) . '<br />' . PHP_EOL; ?> substr works fine, htmlentities and htmlspecialchars don't return anything. Affected: PHP 5.4.X Works fine in 5.3.X and previous. Sincerely, KlemenActually, Windows-1250 is not supported, so to get it to work correctly I used: <?php echo htmlentities( iconv('Windows-1250', 'UTF-8', 'ščćžđ ŠČĆŽĐ') ); ?>