0
我想將unicode字符轉換爲PHP中的文本,但字符串是unicode字符和文本的混合。但它不起作用。讓我解釋一下我的情況。將unicode字符轉換爲php中的文本不起作用
我遵循這個鏈路(Unicode character in PHP string)
<?php
$unicodeChar = "{'singer': u'', 'name': u'\\\\u101c\\\\u1031\\\\u1011\\\\u1032\\\\u101c\\\\u103d\\\\u103e\\\\u1004\\\\u1037\\\\u103a\\\\u101c\\\\u102d\\\\u102f\\\\u1000\\\\u103a'}\\r\\n\\r\\n artist : Thar Gyi\\r\\n album : Sal Pone Ta Pone\\r\\n genre : R&B\\r\\n copyright : MyanmarSongs.NET\\r\\n track : 1\\r\\n title : Lay Htal Hlwint Lite";
echo json_decode('"'.$unicodeChar.'"');
echo mb_convert_encoding($unicodeChar, 'UTF-8', 'HTML-ENTITIES');
echo mb_convert_encoding($unicodeChar, 'UTF-8', 'UTF-16BE'); showing nothing
?>
當該值是Unicode字符和文本等我用混合物所有上述情形不工作。但是,當價值如此簡單時,它正在發揮作用。
$unicodeChar = '\u1000';
echo json_decode('"'.$unicodeChar.'"');
那麼請我該如何做到這一點?
弗里斯特的JSON輸入$ unicodeChar你給我不JSON格式。請給我正確的json。所以我可以檢查它 –
不,它以任何格式。那麼請如何檢測它? –
在php中使用mime_content_type函數http://php.net/manual/en/function.mime-content-type.php –