Umlauts (again) and arraytojson

Trevor DeVore lists at mangomultimedia.com
Thu Apr 9 10:25:01 EDT 2020


On Thu, Apr 9, 2020 at 8:06 AM Klaus major-k via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi friends,
>
> this just came up in the german LC forum, obviously "arraytojson"
> does not like UMLUATS in the keynames!?
>
> This:
> ----------------------
> on mouseUp
>  put "eins" into tArray["äns"]
>  put "zwei" into tArray["zwöi"]
>  put arraytojson(tArray)
> end mouseUp
> ----------------------
> gives -> {}
>
> Is this correct/desired behaviour?


Correct? Yes. The data and keys are not UTF-8 encoded.
Desired? No.

Try encoding the keys and data as UTF-8 before passing to arraytojson.
Arraytojson() uses the mergJSON external and requires UTF-8 data.

----------------------
on mouseUp
 put textEncode("eins", "utf8") into tArray[textEncode("äns", "utf8")]
 put textEncode("zwei", "utf8") into tArray[textEncode("zwöi", "utf8")]
 put arraytojson(tArray)
end mouseUp
--------------------—

You can refer to the following report I filed on the current state of JSON
in LiveCode (which is not good). In my work I use both the JSON Library and
mergJSON as described in the report.

https://quality.livecode.com/show_bug.cgi?id=22478

-- 
Trevor DeVore
ScreenSteps

>



More information about the use-livecode mailing list