|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-09-26 09:24 UTC] nospam at unclassified dot de
Description:
------------
Trying to decode HTML entities into UTF-8 results in the following error message:
Warning: cannot yet handle MBCS in html_entity_decode()!
The line is repeated about 200 times, then html_entity_decode just uses ISO-8859-1 charset.
Reproduce code:
---------------
echo html_entity_decode("ü", ENT_QUOTES, "UTF-8");
Expected result:
----------------
some UTF-8 encoding of '?'
Actual result:
--------------
error messages see above, then Latin-1 encoding of '?'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 04:00:02 2025 UTC |
OK, I found another way for my issue anyway... <?php // Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv) function code2utf($num) { if ($num < 128) return chr($num); if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128); if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); return ''; } function encode($str) { return preg_replace('/&#(\\d+);/e', 'code2utf($1)', utf8_encode($str)); } ?>