I am attempting to use mb_encode_numericentity()
to convert all special UTF-8 characters into HTML entities. The following code converts some characters, like ㋡, but not others, like 𝑥.
echo encodespecial('㋡ ヅ Hello World 𝑥 𝑦 𝑧');
function encodespecial($str)
{
$convmap = array(0x80, 0xffff, 0, 0xffff);
return mb_encode_numericentity($str, $convmap, 'UTF-8');
}
Here is the solution, based on CBroe's explanation:
echo encodespecial('㋡ ヅ Hello World 𝑥 𝑦 𝑧 this is a test....');
function encodespecial($str) {
$convmap = array(0x80, 0xfffffff, 0, 0xfffffff);
return mb_encode_numericentity($str, $convmap, 'UTF-8');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.