montegoulding / mergJSON

JSON encode / decode external for LiveCode
http://mergext.com
GNU General Public License v3.0
13 stars 10 forks source link

mergJson is not support parse Chinese #2

Closed zhangmazi closed 10 years ago

zhangmazi commented 10 years ago

My json contain Chinese and the charset "\uxxxxxxx\uxxxx" example json string: [{"blog_id":"73","title]":"asdasdsadasd","tcolor":"","tbold":"0","short_name":"asdasdsadasd","cat_id":"2","cat_name":"\u751f\u6d3b\u7410\u788e","blog_type":"standard","small_pic":"","hits":"1","post_date":"2014-03-30","status":"1","sticked":"0","keywords":"dd","total_comment":"0","access_way":"1","access_pname":"","nick":"\u5f20\u9ebb\u5b50"},{"blog_id":"72","title]":"asdasdasd","tcolor":"","tbold":"0","short_name":"asdasdasd","cat_id":"3","cat_name":"PHP\u4e4b\u8def","blog_type":"standard","small_pic":"","hits":"1","post_date":"2014-03-30","status":"1","sticked":"0","keywords":"asdasdasd","total_comment":"0","access_way":"1","access_pname":"","nick":"\u5f20\u9ebb\u5b50"}]

My IDE is Livecode 7.0 dp6 On Windows8 bit64

montegoulding commented 10 years ago

mergJSON uses UTF8 encoding so you will need to encode it as UTF16 for use in LiveCode

zhangmazi commented 10 years ago

code: put JSONToArray(str_json) into arr_json

answer uniEncode(arr_json[1]["cat_name"], "utf8")

I had done it. but the result is incorrect Chinese. where is the wrong...please help me.

montegoulding commented 10 years ago

Are you sure the original unicode codepoints are correct and have you tried encoding and decoding the correct Chinese chars to JSON?

zhangmazi commented 10 years ago

I have writed json string at under url. and it responed write header with utf8 charset(no bom) http://www.ninja911.com/json_demo_mobile.php can you take a minute to test it ?

montegoulding commented 10 years ago

I already did do this test and I got what looked like Chinese chars but not knowing Chinese I don't know if they are correct.

zhangmazi commented 10 years ago

I sent a email to your monte@goulding.ws. please receive it.

zhangmazi commented 10 years ago

The issue was solved.

Save the encode string to the unicodeText of field. eg:

set the unicodeText of field "TxtResult" to uniEncode(str_result, "utf8")

After read from the text of field. eg:

answer the text of field "TxtResult"

Thanks.