This site is about Chinese only. If you want to learn about using to use Tcl with other languages such as Korean, Japanese or German, please refer to Scriptics's Introduction to Tcl i18n Features .
Use Tcl version 8.1 or later. You can download Tcl from http://www.scriptics.com .
Tcl version 8.1 or later has built-in support for internationalization. If you are running on a Chinese environment (such as the Chinese version of Microsoft Windows), or if you have installed Chinese font for your non-English environment, displaying Chinese text is just as simple as
button .b -text "\u592a\u9177"
pack .b
Displaying chinese characters on English version of Solaris 7.This should display the Chinese characters Tai-Ku (really cool). If this doesn't work, see the following question.
A simple rule-of thumb is, if you have already configured your web browser to display Chinese characters, Tcl will know how to automatically pick up those fonts to display.I will add some links here about how to install Chinese fonts for Windows and Unix platforms. For the time being, please visit http://www.cnd.org/WWW-HZ/WWWChinese.html
By default, Tk widgets are configured with fonts that do not support Chinese glyphs (e.g, Courier). When you want to display Chinese characters, Tk searches the system font directory and picks the "right" Chinese font. Sometimes the font that Tk picks doesn't quite look right and you might want to choose the font yourself.In this case, you probably need to write some platform specific code, as the font names are different on Unix and Windows, and Tk does not provide portable names for Chinese fonts.
For example, the following code chooses the MingLiu font for the text widget -- MingLiu is a BIG5 font that comes with the Internet Explorer 3.0 International Pack.
To find out what fonts are available on the system, you can use thetext .t -font {-family MingLiU -size 16}
font families
command.
Basically, any font that you can install for Netscape is good for Tcl. Try http://www.cnd.org/WWW-HZ/WWWChinese.html
If you're running on Chinese environment (such as the Chinese version of Microsoft Windows), cut-and-paste between native apps and Tk widgets should work as expected. No special work is required.If you're running on English versions of Win98 or NT 4.0, it should be possible to paste contents of a Netscape window into a Tk widget. Just make sure that before you do a copy operation inside the Netscape window, select the proper character set by using the menu command View, Character Set, Traditional Chinese (or Simplified Chinese.)
Other combinations, such and pasting from NT to Tk, or cutting from Solaris and pasting into Tk, are more complicated. I will write about them later.
Many people use "wrapper" Chinese system such as UnionWay on top of an English version of Windows. When you input a (16 bit) Chinese character in UnionWay, it breaks it down into two 8 bit parts and sends them to TK. You must use theencoding convertfrom
command to convert them back into a single 16 bit character.The following code shows how to change the default Text binding to convert GB text sent from UnionWay before inserting it into a text widgets.
bind Text
{
tkTextInsert %W [encoding convertfrom euc-cn %A]
}
This seems to be a bug in Tcl 8.2. If you want to convert to and from GB text, try using the euc-cn encoding instead.
Mark Harrision's Presentation about How Tcl is used in China (O'Reilly Open Source Conference, 1999.) Scriptics's Introduction to Tcl i18n Features .
Brought to you by Ioi.Lam@zhongwen.htmlplanet.com .