difficulty passing Japanese characters(UTF-8) via

2019-03-05 18:18发布

问题:

Having problems returning a list of Japanese terms from an MSSql database as JSON. If I return them as a bunch of list items all is ok, but I can not seem to get json encode to work for me. Any pointers much appreciated.

$prefs = array();
while($row = mssql_fetch_array($result))
{
$prefs[] =  mb_convert_encoding($row["Pref"] , "UTF-8", "SHIFT-JIS") ; 
    //echo "<li>" . mb_convert_encoding($row["Pref"] , "UTF-8", "SHIFT-JIS") . "</li>";
}

 echo json_encode($prefs);

回答1:

\u611b\u77e5\u770c = 愛知県 (Aichi Prefecture)

\u611b\u5a9b\u770c = 愛媛県 (Ehime Prefecture)

Both are correct Japanese Prefecture name. So string conversion part has no problem.

The perp is hiding in the later phase.



标签: php json utf-8