Unicode

Devin Asay devin_asay at byu.edu
Tue Jan 27 10:50:18 EST 2015


On Jan 26, 2015, at 5:35 PM, Peter Haworth <pete at lcsql.com> wrote:

> Well I guess I spoke too soon :-)  When I said I had things working, I
> meant I could successfully get data from a UTF8 database and display it
> correctly.
> 
> I'm now trying to get input from field controls and get it into the
> database.  I found a lorem ipsum generator that would create text in
> various languages to I got some Russian text from it and pasted it into an
> LC field.
> 
> In my handler, I need to put the contents of the field into a variable and
> then hand it off from there to an INSERT statement. I've tried every
> combination of unicodeText, uniencode, unidecode, or none of the above to
> get the correct value into the variable but it either ends up as question
> marks or something that looks nothing like the characters in the field.
> 
> This is all with pre 7.0.  I think I'm beginning to understand why 7.0 is a
> lot better to use than pre 7.0 when heavy unicode handling is needed!
> 
> But in the meantime, how should I be handling the above situation in pre
> 7.0?
> 

Pete,

I’ve done this a lot pre-7. Here’s the relevant bit of code:

  put unidecode(the unicodeText of line 1 of fld “russStuff","utf8") into tRussTxt

At that point, since the text in tRussTxt is expressed in plain ASCII you can just INSERT it or UPDATE your database. To get it out again you reverse the process:

  set the unicodeText of fld “russStuff” to uniencode(tRussFldFromDB,”utf8”)

LC 7 of course simplifies this process, but you still have to textEncode/textDecode the text as you’re outputting/inputting it.

  put textEncode(the text of fld “russStuff”,”utf8”) into tRussTxt # prep for DB
  
  put textDecode(tRussFldFromDB,”utf8”) into fld “russStuff”  # display text from DB

HTH

Devin


Devin Asay
Office of Digital Humanities
Brigham Young University





More information about the use-livecode mailing list