After PHP json_encode encryption, some Chinese characters show no urgency
$e =mb_detect_encoding ($STR) Output character encoding type, how can this be?
ASCII-------------
UTF-8-------------, Harry
UTF-8-------------, Zhao Liu
ASCII-------------2014-07-16
-------------e-Commerce brand marketing Department
-------------Job Briefing
UTF-8-------------not archived
UTF-8-------------not Sent
-------------Manager's Office
ASCII-------------2
UTF-8-------------After the text is only required to select Xwould after the system will be automatically generated
UTF-8-------------who am I?
ASCII-------------11
ASCII-------------2014
ASCII-------------
-------------Testing Department
ASCII-------------
UTF-8-------------Li Gang, Guo Meimei, Zhao Zhiyong, Zhang Tanxin
ASCII-------------Admin
The total number of periods and year of the-------------work briefings can be automatically generated by the system and can be viewed in the list of posts
UTF-8-------------Research and Development Center
-------------Group leader
-------------Urgent
UTF-8-------------Common
ASCII-------------
ASCII-------------
After using Json_encode array encryption, the output of the Chinese character part is empty, what's the matter?
Heroes, do you have a good solution? Emergency
------Solution--------------------
Your original data is GBK, which cannot be accepted by Json_encode.
Json_encode only accepts UTF-8 encoded data, so GBK characters are discarded because they cannot be recognized.
Only a small number of character combinations have been incorrectly interpreted as utf-8 double-byte characters and have been preserved, causing your doubts, if not left, to make things clearer.
So if you need to generate JSON, you need to do a bit of transcoding.
Array_walk_recursive ($ar, function (& $s) {$s = Iconv (' GBK ', ' utf-8 ', $s);});
If the data is read from MySQL, it is only required to execute once before reading
mysql_query (' Set names UTF8 ');
It's Bob.