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

时间:2021-08-29 20:14:57

How do I convert a utf-8 string to a utf-16 string in PHP?

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

2 个解决方案

#1


13  

mbstring supports UTF-16, so you can use mb_convert_encoding.

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

#2


3  

You could also use iconv.

你也可以使用iconv。

It's native in PHP, but require that all your text is one charset. Else it could discard characters.

它在PHP中是原生的,但要求所有文本都是一个字符集。否则它可以丢弃角色。

#1


13  

mbstring supports UTF-16, so you can use mb_convert_encoding.

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

#2


3  

You could also use iconv.

你也可以使用iconv。

It's native in PHP, but require that all your text is one charset. Else it could discard characters.

它在PHP中是原生的,但要求所有文本都是一个字符集。否则它可以丢弃角色。