Page 1 of 1

Unicode from a PHP script in LiveCode 7.0

Posted: Fri Oct 17, 2014 10:31 pm
by lexogram
Hi LiveCoders!

I understand that in the forthcoming version 7.0, Unicode is handled differently than it has been in the past, and that uniEncode is deprecated.

Apologies in advance for the awkward way in which I have created a URL, so that I can provide a simple example on this forum.

I have created a very simple php script, which returns a string in Serbian:

<?php
header('Content-type: text/xml; charset=utf-8');
echo "Љубазни фењерџија чађавог лица хоће да ми покаже штос.";
?>

You can see that the charset is explicitly set to utf-8. However, when you execute the following line in the Message window...

put "htt" into tURL
put "p://" after tURL
put "dev.lexogram.c" after tURL
put "om/livecode/serbian." after tURL
put "php" after tURL
put URL tURL

... the output is not properly treated. Here it is:

–â—É–±–∞–∑–Ω–∏ —Ñ–µ—ö–µ—Ä—ü–∏—ò–∞ —á–∞—í–∞–≤–æ–≥ –ª–∏—Ü–∞ —Ö–æ—õ–µ –¥–∞ –º–∏ –ø–æ–∫–∞–∂–µ —à—Ç–æ—Å.

In LiveCode 7.0, and without using uniEncode, how should I treat the incoming string so that it appears correctly?

Thanks in advance,

James

Re: Unicode from a PHP script in LiveCode 7.0

Posted: Fri Oct 17, 2014 11:10 pm
by LCNeil
Hi James,

Check out the new "textDecode" function thats present in 7.0. More info on this and any other unicode specific "things to look out for" can be found in the 7.0 release notes :)

Adding textDecode to your script returns the text as expected-

Code: Select all

on mouseUp
   put "htt" into tURL
   put "p://" after tURL
   put "dev.lexogram.c" after tURL
   put "om/livecode/serbian." after tURL
   put "php" after tURL
   put URL tURL into tData
   put textDecode(tData, "UTF8") into field "text"
end mouseUp
I hope this gives you some leads.

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

Re: Unicode from a PHP script in LiveCode 7.0

Posted: Fri Oct 17, 2014 11:33 pm
by lexogram
Thanks Neil! That works.