Translating escape sequences

Peter TB Brett peter.brett at livecode.com
Wed Mar 15 07:53:10 EDT 2017



On 14/03/2017 21:26, J. Landman Gay via use-livecode wrote:
> I'm dealing with non-English languages, and JSON data retrieved from a
> database comes in with unicode escape sequences like this: Eduardo
> Ba\u00f1uls.
>
> I need to translate those. I can do it by replacing the "\u" with "0x"
> and then using numToCodepoint() to get the UTF16 character. But there
> could be many of these in the same string, so I'm looking for a one-shot
> command that might just do them all. I don't think we have one.
>
> The alternative is to loop through all the text, getting an offset for
> each "\u" and then calculating the number of characters after that to
> use with numToCodepoint(). But will it always be 4 characters in any
> language?
>
> Or is there an easier way?

JsonImport() should handle those automatically.  Please let me know if 
it doesn't!

                                         Peter

-- 
Dr Peter Brett <peter.brett at livecode.com>

lcb-mode for Emacs: https://github.com/peter-b/lcb-mode




More information about the use-livecode mailing list