Accented Characters Display

Mark Schonewille m.schonewille at economy-x-talk.com
Thu Apr 7 19:40:11 EDT 2011


Hi,

The whole idea of using unicode is that you don't need isoToMac anymore.

If you happen to be storing unicode data in a database that isn't encoded as unicode, then it simply won't work. What is the encoding of the database? Is it actually UTF8?

There's a good chance that LiveCode is unable to retrieve the unicode data directly from the MySQL database, because LiveCode cannot retrieve binary data from the command line, externals and (database) drivers. LiveCode can, however, retrieve binary data through sockets. If you make a simple PHP script, which shold reside on the server and can be called by LiveCode using the put URL command, then you will be able to retrieve correct unicode data.

Once you got the PHP script, you should be able to execute a simple script like this:

put "http://domain.com?query=read&name=john&city=new%20york" into myUrl
put url myUrl into myData
put uniencode(myData,"UTF8") into myData
set the unicodeText of fld "Foo" to myData

To save the data you need to do something like this:

put urlEncode(unidecode(the unicodeText of fld "Name","UTF8")) into myName
put urlEncode(unidecode(the unicodeText of fld "City","UTF8")) into myCity
put "http://domain.com?query=write&name=" & myName & "&city=" & myCity into myUrl
get url myUrl

This is just an example to inspire you. The above won't work with your set-up.

I delivered a project yesterday, which is based on this mechanism: always convert your data to UTF8 before saving it and convert it back to unicode (UTF16) when retrieving it. Make sure that the database is UTF8 capital insensitve encoded.

Why store as UTF8 and not as UTF16? Because you don't want to mess with little and big endian.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce

On 7 apr 2011, at 22:35, Devin Asay wrote:

> 
> On Apr 7, 2011, at 2:16 PM, Thomas Coder wrote:
> 
>> We’re having some trouble with accented characters and hoping someone can
>> shed some light on the topic.
>> 
>> We have data in a MySQL database that contains accented characters like
>> “Nuñéz”, and we want it to display correctly in a datagrid.
>> 
>> When we retrieve the data, LiveCode sees it as this: NuÒÈz
>> 
>> When we try this:
>> set the unicodeText of fld "Field" to uniencode(t, "UTF8")
>> 
>> the words appears with a square character instead of the “ñé” characters.
>> 
>> Is there a magic combination of code that fixes this?
> 
> Thomas,
> 
> I'm guessing you're on a Mac?
> 
> What happens when you do this:
> 
> -- retrieve the data from your database into variable t
> put isoToMac(t) into fld "displayfld"
> 
> The root of your problem is probably that the data is not stored in the database as UTF-8. If it were, the 'set the unicode ...' statement would work. Also, make sure that the textFont for the destination field is set to a unicode font to ensure all of the characters display.
> 
> Hope this helps.
> 
> Devin
> 
> 
> Devin Asay
> Humanities Technology and Research Support Center
> Brigham Young University
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list