Search code examples
unicodelivecode

Pulling Unicode Data from a DataGrid in LiveCode


We're translating our app into Japanese and have been struggling to get UTF-16 text from a DataGrid. We've tried all sorts of combinations of uniEncode, uniDecode on the data and it all comes out garbled. We first overrode the DataGrid, so we can see that the Japanese in the datagrid is correct. But, when we pull it out using GetDataOfLine or dgDataOfLine and then try to decode it, it is garbled. Current thinking is that we need to create another handler like GetUnicodeDataOfLine. Any ideas?


Solution

  • The datagrid doesn't modify the dgData unless the user edits something at which point it's up to you to get the unicodeText of the field editor. If you are using dgText though I'm not sure what it will do.


    EDIT

    The uni functions always expect UTF16. So the second parameter is what you are coming from in uniEncode and what you want to go to in uniDecode. So uniDecode(var,"UTF8") takes UTF16 data and returns UTF8 data. uniEncode(var,"UTF8") takes UTF8 data and returns UTF16 data.