Odd behaviour with Russian text
devin_asay at byu.edu
Wed Feb 23 11:36:07 EST 2011
On Feb 23, 2011, at 6:22 AM, Lars Brehmer wrote:
> A very strange thing is happening with some Russian text fields and custom properties!
> Rev version 2.8, MacOS10.6
> I am putting Russian text stored as a custom property into a field. The textfont of the field is Arial,Russian, and until now this has functioned perfectly. I liked the way that support for Russsian eliminates the need to use uniEncode, uniDecode, unicodeText, etc.
> But now when I put the text into a field containing more than 1 line, the text becomes that gibberish (loks kind of like oriental characters and wierd symbols), as if I was making a mistake with unicode text like I used to. But this only happens when a capital letter is present! If I eliminat the caps, it works, and it also works with a cap in a single field with just 1 line!
> Anyone know what is causing this?
It's likely that the problem is that certain characters in the ASCII range, like return, are rendered as single byte characters, whereas the surrounding unicode text is double byte. This ends up throwing off the byte pairs, resulting in incorrect rendering of all of the characters following the ASCII range character. Another possible cause is that the original unicode text in the custom property was generated on a system whose CPU has different endian-ness from the system you are showing the text on.
I've found that it's more reliable to store UTF-8 text in your custom property, then use uniEncode to convert it to UTF-16 when you're displaying it in a field (or button or whatever.) Another option is to store the unicode text as htmlText in your custom property, but in that case you have to be careful to specify an appropriate font for the platform you're displaying it on.
Humanities Technology and Research Support Center
Brigham Young University
More information about the Use-livecode