Unicode text for buttons, etc
devin_asay at byu.edu
Wed Dec 20 11:34:24 EST 2006
On Dec 20, 2006, at 8:11 AM, Carly J. Born wrote:
> I'm new to using RunRev and so forgive me if this has been covered
> in a previous thread.
No worries, Carly. Unicode is a puzzlement to almost everyone when
they first start to use it. One key to remember is that Revolution's
unicode is always UTF-16. The other key is that Revolution always
uses the byte order of the host CPU, so developing cross-platform
unicode-using stacks can be tricky.
> I'm looking for a method of delivering what will potentially become
> a digital foreign language textbook, for which I need full Unicode
> support. I'm playing with the trial version and am having a hard
> time getting Unicode to 'stick' in simple button labels. Sometimes
> the characters stick (after retyping a few times) and sometimes I
> just can get them to stay and get jumbled up.
> My questions are:
> - is there a way to set the default font of the entire stack
> during development? (the setting I found also doesn't seem to stick)
It seems to work best to set the font for each object when using
unicode text. For unicode button labels, set the font of the button
to a unicode font *before* entering the text. A unicode font is in
two parts, like this:
set the textFont of btn "CyrillicButton" to "Geneva CY,Russian"
You can also set the font directly in the property inspector by
entering a 2-part font name. The language name that comes after the
font name is one of any from this list (from the Documentation
>Dictionary under uniEncode):
* ANSI (synonym for "English")
* Japanese (Shift-JIS)
* Russian (Cyrillic)
* SimpleChinese (Simplified Chinese)
* Unicode (UTF-16)
* w (synonym for "Unicode")
Once the button's font is set, try typing the label in the desired
language, using the OS's built-in input methods. Even after you have
done this you may find that part of the label goes whacky, especially
if the label contains a space. This is because Revolution treats
ascii-range punctuation characters (including space) as ascii, not
unicode, which throws off the byte count for any characters following
the space. (I know, it's weird, but this is the current state of
affairs.) I find it is pretty reliable, however, if you use an
Create a field, set its textFont to a unicode font, eg. Geneva
Place your insert cursor into the field, select the desired language
input method, and type the label text.
In the message box execute this command: set the label of button
"CyrillicButton" to the unicodetext of line 1 of fld "unicodefld"
This should display the text reliably, and it should "stick".
> - is Unicode reliably usable within the authoring environment?
> (I've seen a few references to calling unicode text files, is that
> the only way?)
It is reliable-ish if you learn how to use it. Displaying unicode
text is pretty reliable, but user input of unicode is problematic,
especially with right to left languages like Hebrew and Arabic, for
which there are verified, unresolved bugs.
Rev reads in unicode files reliably. Here is an example of a button
handler that will read in a UTF-16 encoded file:
answer file "Choose a unicode file to read in."
if it is empty then exit mouseUp
put "binfile:" & it into urlName
set the unicodeText of fld "display" to url urlName
> - Do you have any recommendations for working with unicode foreign
> languages in RunRev?
Aside from the above, learn all you can about unicode. That'll make
it easier to follow how Rev implements it. Don't get discouraged; a
number of people are using it successfully. Ask questions here.
Humanities Technology and Research Support Center
Brigham Young University
More information about the Use-livecode