GB2312:外国生产
GBK2312:中国生产
用百度开发平词法分析,必须把你发送的内容设置成GBK编码,但是返回的是string json类型,没法用json_decode()成功转化,通过json_last_error()得到错误代码5,通过json_last_error_msg(). 一查文档说可能是字符编码不正确。
mb_detect_encoding() 输出字符串编码类型,结果是UTF-8,不应该啊,我在PHP文件一开始设置了
header("Content-type:text/html;charset=gbk2312"); 那应该是gbk.
mb_convert_encoding($response."UTF-8","GB2312"); 结果json_decode() 可以转化成json了。
GBK2312:Chinese standard
GB2312:foreign standard
Today I user baidu Word parse to parse a sentence. But you must post data which is GBK encoding.
So according to his request. I get a string json which doesn't use json_decode() to transform.
The next I ues json_last_error() and json_last_error_msg() get code 5 . I find PHP manual to find cause.
The cause is UTF-8 encoding and it's not right.
mb_convert_encoding($response."UTF-8","GB2312"); finally the json_decode() is running well.