문제

In C++, it's possible create a UTF-8 string using this kind of notation: "\uD840\uDC50".

However this doesn't work in PHP. Is there a similar notation?

If not, is there any built-in way to create a UTF-8 string knowing its Unicode code point?

도움이 되었습니까?

해결책

I've ended up implementing it like this:

$utf8 = html_entity_decode("一", ENT_COMPAT, 'UTF-8');

다른 팁

function hexToString($str){return chr(hexdec(substr($str, 2)));}
$result = preg_replace_callback("/(\\\\x..)/isU", function($m) { return hexToString($m[0] ); }, $str);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top