My issue is this: I use Facebook to get a list of friends of a user and am having trouble with international characters in names.
I take the JSON object Facebook provides, use json.decode on it creating a table that is then edited some in my program. I then use JSON.encode on that table. I write that encoded JSON to a file to be read back.
The issue is that any name that includes international characters is treated as being nil and is not being read back properly. When I try to open the .json file directly from the documents directory of the simulator Dashcode warns me that there is no text encoding present on the file. Other text editors like BBEdit open the file but default to “Western (Mac OS Roman)” encoding.
I understand that Facebook provides the response in Unicode-8 and that Corona/LUA should properly handle the international characters, so I am assuming that at some point during the JSON decoding/encoding or writing to the same to a file, something is getting lost.
The following is a snippet of the code that i am using to encode the table and write the file:
local string = json.encode(friendsByIDwithGender)
local tmp = io.output() -- save current file handle
local path = system.pathForFile( ""..currentID.."FriendsByIDwithGender.json", system.DocumentsDirectory )
io.output( path ) -- open new file in text mode
io.write( string ) -- write the file
io.output():close() -- close the file
io.output( tmp ) -- restore the previous file
Is there a way to set the text encoding for the file from Corona or a different way to create the file that will include the text-encoding? Or is there an issue with json.encoding/decoding that will always cause this issue?
Thanks for any help. [import]uid: 8666 topic_id: 19089 reply_id: 319089[/import]