开发者

Unicode character in octets to hexadecimal

开发者 https://www.devze.com 2023-01-19 03:44 出处:网络
Unicode character in octets is something like 110xxxxx 10xxxxxx. How can I transform these octets in hexadecimal notation like开发者_StackOverflow社区 U+XXXX?You can leverage iconv\'s UTF-8 decoder to

Unicode character in octets is something like 110xxxxx 10xxxxxx. How can I transform these octets in hexadecimal notation like开发者_StackOverflow社区 U+XXXX?


You can leverage iconv's UTF-8 decoder to avoid having to write one yourself:

function utf8_to_codepoints($s) {
    return unpack('V*', iconv('UTF-8', 'UCS-4LE', $s));
}

$data= "Caf\xc3\xa9 \xe6\x97\xa5\xe6\x9c\xac \xf0\x9d\x84\x9e"; // Café 日本 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号