Character encoding issue

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
scunnercampbell
Posts: 3
Joined: Wed Mar 13, 2013 4:29 pm

Character encoding issue

Post by scunnercampbell » Wed Mar 20, 2013 4:13 pm

Hi. I'm having a problem trying to use HTMLtext to display HTML entities correctly in my LiveCode app. An example is the British pound sign, which is encoded in the XML file where LiveCode is reading in the data:
E.g £3 is encoded in XML as...
 3

But when displayed in LiveCode with HTMLtext, I get, the "not" symbol before the £:

£3

Another example is right closing quotes, encoded as ’ but displayed as Äô

Is there a way round this? A character encoding setting within LiveCode? The database where the content is stored, before being added to the XML file, has character encoding utf8.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Character encoding issue

Post by Simon » Wed Mar 20, 2013 9:13 pm

Hi scunnercampbell,
I'm seeing the pound symbol as £ in HTML
  looks like nbsp?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

n9yty
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 52
Joined: Thu Feb 28, 2013 11:33 pm

Re: Character encoding issue

Post by n9yty » Wed Mar 20, 2013 10:15 pm

Try something like:

set the htmlText of field "fieldname" to utfdecode( utfencode( yourTextVar, "UTF8" ) )

UGH: That's what I get for going my bad memory... uniDecode( uniEncode( yourTextVar, "UTF8" ) )

I had UTF on the brain. :)

I think that worked for me, except on Android for some reason.
Last edited by n9yty on Thu Mar 21, 2013 2:49 am, edited 1 time in total.

scunnercampbell
Posts: 3
Joined: Wed Mar 13, 2013 4:29 pm

Re: Character encoding issue

Post by scunnercampbell » Thu Mar 21, 2013 12:31 am

n9yty wrote:Try something like:

set the htmlText of field "fieldname" to utfdecode( utfencode( yourTextVar, "UTF8" ) )

I think that worked for me, except on Android for some reason.
Thanks...I tried that, but results in an empty field. Are those functions definitely available? I can't seem to find any docs on them.

set the HTMLtext of fld "F_AttractionsDetail" to utfdecode( utfencode( gAttractionInfo, "UTF8" ) ) -- results in blank field
set the HTMLtext of fld "F_AttractionsDetail" to gAttractionInfo -- results in field populated but with same issues described in first post

n9yty
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 52
Joined: Thu Feb 28, 2013 11:33 pm

Re: Character encoding issue

Post by n9yty » Thu Mar 21, 2013 2:50 am

Sorry, my bad, I fixed it above... uniEncode/uniDecode not utf... I had a UTF hangover apparently. LoL

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”