如何在 PHP 中将 utf-8 字符串转换为 utf-16 字符串

How to convert a utf-8 string to a utf-16 string in PHP

提问人:Freddo411 提问时间:10/1/2008 更新时间:10/5/2016 访问量:26050

问:

如何在 PHP 中将 utf-8 字符串转换为 utf-16 字符串?

PHP 的UTF-8 UTF-16

评论


答:

14赞 chroder 10/1/2008 #1

mbstring 支持 UTF-16,因此您可以使用 mb_convert_encoding

3赞 Jesper Grann Laursen 5/23/2009 #2

您也可以使用 iconv

它是 PHP 中的原生语言,但要求所有文本都是一个字符集。否则,它可能会丢弃字符。