我可以帮助您将普通字符串转换为UTF-8编码的函数或简单算法。
例如: 字符串:
例如: 字符串:
hello
عربي
UTF-8编码:
68 65 6C 6C 6F 0A 0639 0631 0628 064A 0A
hello
عربي
UTF-8编码:
68 65 6C 6C 6F 0A 0639 0631 0628 064A 0A
使用 utf8_encode($data)
iconv("windows-1256","utf-8",$txt);
。 - Salem使用iconv
,如下所示:
$text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
这也可以检测字符串当前的字符集。
试一下这个:
...
$somStr = 'Hello';
utf8_encode_deep($somStr); // Converting string to utf8
print_r($somStr);
...
有关utf8_encode_deep()
的更多详细信息,请参见this
希望它能解决这个问题。
iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
。 - GBD