On Android builds only, (I tested on several versions, including the lastest Build 977), there is something strange going on with network.request responses, which don’t handle UTF-8 strings correctly… it seems they do a UTF-8 encode preprocessing step. The problem is then you’ll get a UTF-8 encoded string that safely encodes all those magic UTF-8 bytes.
So instead of getting the correct test response of
["¡Baño!","¿café?","????"]
I get
["¡Baño!","¿café?","è¿?æ?¥å?¬é?"]
but only on Android, not simulator or iOS.
The solution is to do an extra decode step using this code, on the string before sending it to json.decode. but only when running on an Android device.
http://developer.coronalabs.com/code/utf-8-encode-and-decode
something like this:
function better\_json\_decode(input)
local s = input
if platform=='Android' then
s = utf8\_decode(s)
end
return json.decode(s)
end
Anyone know the proper way to get android builds to behave correctly here? [import]uid: 122310 topic_id: 33775 reply_id: 333775[/import]