📄 00000001.htm
字号:
An equivalent Spanish-language message file, es.msg, would contain: <BR> <BR>∶<I>:msgcat::mcset es "Welcome to Tcl!" "隆Bienvenido a Tcl!" </I><BR>∶<I>:msgcat::mcset es "Select a color:" "Elige un color:" </I><BR>Internationalization and the Tcl C APIs <BR>Tcl 8.1 introduces new C APIs to support all new internationalization <BR>features. Tcl 8.1 also introduces new convenience functions for <BR>manipulating Unicode/UTF-8 strings. By using the new APIs in your <BR>applications, you can easily add full Unicode support to your <BR>application. Coupled with Tk's powerful font and layout support, you can <BR> quickly create fully internationalized applications. <BR> <BR>When programming with the Tcl C APIs, you should be aware of the <BR>following issues, in addition to the Tcl scripting language <BR>internationalization features: <BR> <BR>The Tcl C APIs now require all strings to be passed to functions as <BR>Unicode characters in UTF-8 format. You must convert strings in native <BR>system encodings to UTF-8 before passing them to Tcl C functions. <BR>Similarly, you must convert Tcl UTF-8 strings to the native system <BR>encoding before passing them to system functions. Tcl provides functions <BR> for handling encodings and converting strings from one encoding to <BR>another. See the GetEncoding.3 reference page for details. <BR>Because 7-bit ASCII characters have the same encoding in UTF-8 format, <BR>legacy code that uses only 7-bit ASCII characters functions the same <BR>in Tcl 8.1 as it did in Tcl 8.0. Therefore, if you're certain that <BR>your strings contain only 7-bit ASCII characters, no conversion is <BR>required. <BR>Because strings in Tcl are now stored as Unicode characters in UTF-8 <BR>format, the number of characters in a string is not necessarily equal to <BR> the number of bytes in a string. In particular, you should no longer <BR>use the standard C string functions such as strlen to count characters <BR>in a string. Similarly, other standard C string functions such as <BR>toupper don't work with Unicode characters. Tcl provides a set of <BR>equivalent Unicode string functions, such as Tcl_NumUtfChars and <BR>Tcl_UtfToUpper, as well as other convenience functions for <BR>manipulating Unicode strings. See the Utf.3 and UtfToUpper.3 reference <BR>pages for details. <BR>Summary: Tcl Internationalization Support at a Glance <BR>The following list is a quick summary of the issues you should be <BR>aware of concerning the new internationalization support introduced in <BR>Tcl 8.1: <BR> <BR>Tcl encodes all strings internally as Unicode characters in UTF-8 <BR>format. <BR>The introduction of Unicode/UTF-8 encoding requires no changes to legacy <BR> Tcl scripts that use only 7-bit ASCII characters, because UTF-8 <BR>characters corresponding to the standard 7-bit ASCII set (up to ASCII <BR>value 0x7F in hexadecimal) have the same byte values in both UTF-8 and <BR>ASCII encoding. Furthermore, because the use of Unicode/UTF-8 encoding <BR>is internal to Tcl, most string handling in legacy Tcl scripts works the <BR> same in Tcl 8.1 as it did in Tcl 8.0. <BR>You can specify a Unicode character by its four-digit, hexadecimal <BR>Unicode code value with the "\uxxxx" escape sequence. <BR>All Tcl string functions properly handle multi-byte UTF-8 characters <BR>as single characters. <BR>Tk widgets that display text accept text string arguments in standard <BR>Unicode/UTF-8 encoding. Tk automatically handles any encoding conversion <BR> necessary to display the characters in a particular font. If the master <BR> font that you set for a widget doesn't contain a glyph (a visual <BR>representation) for a particular Unicode character, Tk attempts to <BR>locate a font that does. Where possible, Tk attempts to locate a font <BR>that matches as many characteristics of the widget's master font as <BR>possible (for example, weight, slant, etc.). In some cases, Tk is unable <BR> to identify a suitable font, even if one is actually installed on the <BR>system. Therefore, for best results, you should try to select as a <BR>widget's master font one that is capable of handling the characters <BR>you expect to display. <BR>The system encoding is the character encoding used by the operating <BR>system. Tcl automatically handles conversions between UTF-8 and the <BR>system encoding when interacting with the operating system. <BR>Tcl usually can determine a reasonable default system encoding based <BR>on the platform and locale settings, but if for some reason it cannot, <BR>it uses ISO 8859-1 as the default system encoding. You can explicitly <BR>set the system encoding used by Tcl with the encoding system command. <BR>By default, Tcl uses the system encoding when reading from and writing <BR>to channels, and converts the text to UTF-8 format. You can change the <BR>character encoding for a channel using the fconfigure -encoding command. <BR> <BR>The source command always reads files using the system encoding. <BR>Therefore, Scriptics recommends that whenever possible, you author <BR>scripts in the native system encoding. Furthermore, most common <BR>character encodings include the standard 7-bit ASCII characters as a <BR>subset, so you are usually safe writing scripts using only 7-bit ASCII <BR>characters. You can execute a script written in a different encoding <BR>by opening the file, setting the proper encoding using the fconfigure <BR>-encoding command, reading the file into a variable, and then evaluating <BR> the string with the eval command. <BR>You can convert a string to a different encoding using the encoding <BR>convertfrom and encoding convertto commands. <BR>Tcl has built-in knowledge of approximately 30 common character <BR>encodings. The encoding names command displays a list of all known <BR>encodings. You can create additional encodings as described in the <BR>Tcl_GetEncoding.3 reference page. <BR>The new msgcat package provides a set of functions for managing <BR>multilingual user interfaces. It allows you to define strings in a <BR>message catalog, which is independent from your application and which <BR>you can edit or localize without modifying the application source code. <BR> See the msgcat.n reference page for more information. <BR>You should also read the "Internationalization and the Tcl C APIs" <BR>section of this document if you use the Tcl APIs in C programs. <BR> <BR> <BR> <BR> <BR> <BR>-- <BR> 桃花坞里桃花庵,桃花庵下桃花仙;桃花仙人种桃树,又摘桃花卖酒钱。 <BR> 酒醒只在花前坐,酒醉换来花下眠;半醒半醉日复日,花落花开年复年。 <BR> 但愿老死花酒间,不愿鞠躬车马前;车尘马足富者趣,酒盏花枝贫者缘。 <BR> 若将富贵比贫贱,一在平地一在天;若将贫贱比车马,他得驱驰我得闲。 <BR> 别人笑我忒疯癫,我笑他人看不穿;不见五陵豪杰墓,无花无酒锄做田。 <BR> <BR> <BR>※ 来源:·BBS 水木清华站 smth.org·[FROM: 202.204.7.234] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -