PHP:将 unicode 代码点转换为 UTF-8

2021-12-26 00:00:00 unicode utf-8 php

我的数据格式如下:U+597D 或类似这样的 U+6211.我想将它们转换为 UTF-8(原始字符是好和我).我该怎么做?

I have my data in this format: U+597D or like this U+6211. I want to convert them to UTF-8 (original characters are 好 and 我). How can I do it?

推荐答案

$utf8string = html_entity_decode(preg_replace("/U+([0-9A-F]{4})/", "&#x\1;", $string), ENT_NOQUOTES, 'UTF-8');

可能是最简单的解决方案.

is probably the simplest solution.

相关文章