Unicode from a PHP script in LiveCode 7.0

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lexogram
Posts: 13
Joined: Fri Oct 17, 2014 6:58 pm

Unicode from a PHP script in LiveCode 7.0

Post by lexogram » Fri Oct 17, 2014 10:31 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Unicode from a PHP script in LiveCode 7.0

Post by LCNeil » Fri Oct 17, 2014 11:10 pm

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
--

lexogram
Posts: 13
Joined: Fri Oct 17, 2014 6:58 pm

Re: Unicode from a PHP script in LiveCode 7.0

Post by lexogram » Fri Oct 17, 2014 11:33 pm

Thanks Neil! That works.

Post Reply