难以通过json_encode传递日文字符(UTF-8) [英] difficulty passing Japanese characters(UTF-8) via json_encode
本文介绍了难以通过json_encode传递日文字符(UTF-8)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从MSSql数据库以JSON格式返回日语术语列表时遇到问题. 如果我将它们作为一堆列表项返回,则一切正常,但我似乎无法获得json编码对我有用. 任何指针都值得赞赏.
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);
推荐答案
\ u611b \ u77e5 \ u770c =爱知県(爱知县)
\u611b\u77e5\u770c = 愛知県 (Aichi Prefecture)
\ u611b \ u5a9b \ u770c =爱媛県(爱媛县)
\u611b\u5a9b\u770c = 愛媛県 (Ehime Prefecture)
两者都是正确的日本地区名称. 因此,字符串转换部分没有问题.
Both are correct Japanese Prefecture name. So string conversion part has no problem.
perp隐藏在后面的阶段.
The perp is hiding in the later phase.
这篇关于难以通过json_encode传递日文字符(UTF-8)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文