UTF-16 PHP 字符串转 UTF-8

use*_*914 3 php encoding utf-8 utf

$str使用 成功解密 AES 密码后,我在变量上有一个字符串mcrypt_decrypt。如果我尝试打印str到屏幕,我确实注意到每个字母之间有一个空格,这实际上是NULL termination (\x00)UTF-16字符编码给出的。

Array ( [1] => 33 [2] => 0 [3] => 34 [4] => 0 [5] => 35 [6] => 0 ... )

我尝试了很多方法来改变它,UTF-8但都失败了。我能做些什么?

Mat*_*aga 5

您应该使用mb-convert-encoding函数

$str = mb_convert_encoding($str, "UTF-8" , "UTF-16LE");
Run Code Online (Sandbox Code Playgroud)