JSON, URL-encode, and UTF-8

Peter W A Wood peterwawood at gmail.com
Fri Aug 21 02:58:12 CEST 2015


> On 21 Aug 2015, at 07:35, J. Landman Gay <jacque at hyperactivesw.com> wrote:
> Right. Works without header in 6, fails in 7. Thanks for looking at my file. I wonder what would happen if I use the LC 6 libURL script in LC 7. Will my unicode go all wonky? The file I sent you is in English but most of the time it won't be.

I ran a very simple test using the message box and a very simple PHP script. I was able to post json={JSON} to PHP and get it back.

In the message box (using LC 7..0.3)

post textEncode("json={" & quote & "é" & quote & ": 1}", "UTF-8") to  URL "http://Localhost/jacque.php"
put textDecode(it, "UTF-8”)

The PHP script:


The result in the message box:

{"é": 1}

This would indicate your issue is not caused by a bug.

I’m not sure if you are URLEncoding the data … that certainly seems to cause a problem

Revised LiveCode
put textEncode("{ " & quote & "é" & quote & ": 1}", "UTF-8") into tJSON
put "json=" before tJSON
post URLEncode(tJSON) to URL "http://Localhost/jacque.php"
put textDecode(it, "UTF-8”)

PHP sends back an empty response.

Hope this is of some help.


More information about the use-livecode mailing list