且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP-将字符串转换为unicode

更新时间:2023-02-19 20:22:48

Unicode不是真正的编码;它是总体标准的名称,主要由Microsoft用作UTF-16BE的别名,显然,PHP为此支持它。您期望的是UTF-16LE,因此请明确使用它:

"Unicode" is not a real encoding; it's the name of the overarching standard and used as an alias for UTF-16BE mostly by Microsoft, and apparently PHP supports it for that reason. What you expect is UTF-16LE, so use that explicitly:

$source = mb_convert_encoding('test', 'UTF-16LE', 'UTF-8');