Translating escape sequences

J. Landman Gay jacque at hyperactivesw.com
Tue Mar 14 17:26:48 EDT 2017


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?

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list