我在 php 中保存了一条记录“فحص الرسالة العربية”,该记录始终保存为:
فحص الرسالة العربية
我想在检索它时将其转换为 UTF-16BE 字符,因此我使用了一个返回的函数:
002600230031003600300031003b002600230031003500380031003b002600230031003500380039003b0020002600230031003500370035003b002600230031003600300034003b002600230031003500380035003b002600230031003500380037003b002600230031003500370035003b002600230031003600300034003b002600230031003500370037003b0020002600230031003500370035003b002600230031003600300034003b002600230031003500390033003b002600230031003500380035003b002600230031003500370036003b002600230031003600310030003b002600230031003500370037003b
这是 m 用于转换从数据库检索到的字符串的函数
function convertCharsn($string) {
$in = '';
$out = iconv('UTF-8', 'UTF-16BE', $string);
for($i=0; $i<strlen($out); $i++) {
$in .= sprintf("%02X", ord($out[$i]));
}
return $in;
}
但是当我在下面的 url 中输入相同的字符时,它显示的字符与我的字符串不同。 http://www.routesms.com/downloads/onlineunicode.asp
返回:
0641062D063500200627064406310633062706440629002006270644063906310628064A0629
我希望我的字符串在上面的 url 中被转换时被转换。我的数据库排序规则是 utf-8_general_ci