Why do I still need MacToISO, when working with UTF-8?

Mark Waddingham mark at livecode.com
Mon Jan 16 12:30:23 EST 2017

Hi Matthias,

On 2017-01-16 18:25, Matthias Rebbe via use-livecode wrote:
> It would have been nice if you had also put some sample code for how
> to UTF8 encode the string.
> That would have made your explanations complete. ;)

Sure - here is how I'd slightly adjust Tiemo's code:

*put fld "name" into myName*
-- ...
*open file myFile for binary write*
*write textEncode(myName, "utf8") to file myFile*
*close file myFile*
-- ...
*open file myFile for binary read*
*read from file myFile until EOF*
*close file myFile*
*put textDecode(it, "utf8") into myName*
-- ...
*put URL ("http://myUser:myPW@myURL" & "mySQL.php?" & 
URLEncode(textEncode(theName, "utf8")))
into rslt*
-- mySQL.php writes to a MySQL db, where theName column is encoded as

The missing piece here is PHP configuration on the other side. I'm 
assuming that PHP is doing the following:
    1) URLDecode the part after '?' into bytes
    2) Interpret the bytes as Latin-1 encoded text
    3) Passing the text string to the appropriate MySQL function
    4) The MySQL function is converting the text string to UTF-8

This may or may not be the case. If 'theName' is encoded as UTF8 before 
being URLEncode, all that needs to be checked is that the PHP (on the 
other end) is decoding it into a string as UTF-8 before passing it to 

Warmest egards,


Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

More information about the Use-livecode mailing list