Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用 PHP 在 UCS-2 Little Endian 文件中写入一些信息,这样当我在编辑器中打开该文件时,编码设置为 UCS-2 Little Endian,如附图所示。
我该怎么办?
您可以使用 iconv:iconv('UTF-8', 'UCS-2LE', $string); 此外,您需要将 BOM 附加到结果文件 ( "\xFF\xFE")。
iconv('UTF-8', 'UCS-2LE', $string);
"\xFF\xFE"
然后我的记事本++ 将编码设置为您的图片。
您可以使用 iconv() 来转换字符集。检查命令行上的“iconv --list”以获取支持的编码列表。