The code is as follows
|
Copy code
$array = array
(
'title'=>iconv('gb2312','utf-8','This is the Chinese title'),
'body'=>'abcd...'
);
echo json_encode($array);
?>
Results
{"title":"u8fd9u91ccu662fu4e2du6587u6807u9898","body":"abcd..."}
It’s not what we thought, then we use the php urlencode() function to process the following. Before json_encode, use urlencode() to process all the contents of all arrays
This way there will be no problem with Chinese.
http://www.bkjia.com/PHPjc/632254.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632254.htmlTechArticleChinese often encounters problems intentionally or unintentionally in PHP development. Today we will take a look at the solution to json_encode Chinese garbled characters. There is a way, although the method is not very good, but it can solve the problem with just code...
|
|