unicode from a rev cgi

Devin Asay devin_asay at byu.edu
Wed Dec 31 12:04:17 EST 2008


On Dec 31, 2008, at 6:39 AM, Jim Sims wrote:

> I have a rev cgi that saves text from a form in a web page.
>
> I am testing the input of a language that requires unicode into that
> form
> (the example I am using is the Greek word for small horse "μικρό
> άλογο").
>
> The cgi saves that text to a text file from which I can retrieve it.
>
> It looks like this after I get the url that contains it from the  
> server:
> %26%23956%3B%26%23953%3B%26%23954%3B%26%23961%3B%26%23972%3B+
> %26%23940%3B%26%23955%3B%26%23959%3B%26%23947%3B%26%23959%3B
>
>
> After  I urldecode the above, it looks like this:
>
> μικρό άλογο
>
> How would I change the unicode shown above back into the original
> Greek text?
>
> [those appear to be the correct chars - if I do this locally and then
> save those
> Greek words with the htmlText, they are the same items (in addition to
> the
> html formating tags, of course)]

Sims,

If you get the text back as html entities like this you may have to  
add in the font tags in your scripting. It would probably be  
sufficient to note which tags are added when you do it locally and  
prepend/append them. The one trick is that the space character is not  
unicode, so you'd have to surround each word by font tags.  Here's  
what I came up with when I did a quick test (beware line wrapping):


  put "μικρό άλογο"  
into decodedText
    repeat for each word tWord in decodedText
       put "<font face=" &quote& "Geneva" &quote && "lang=" &quote&  
"en-UC" & quote & ">" before tWord
       put "</font>" after tWord
       put tWord & space after taggedText
    end repeat
    put taggedText--> yields: <font face="Geneva" lang="en- 
UC">μικρό</font> <font face="Geneva" lang="en- 
UC">άλογο</font>
    set the htmltext of fld 1 to taggedText

(Ugly, I know, but it works.)

As an alternative, would it be possible to encode the unicode text  
from the form as UTF-8 before saving it to the text file? At least it  
would be a bit cleaner that way.

HTH

Regards,

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list