Going Global With Text

星期三, 三月 12, 2008 20:00
Posted in category 工作

A number of issues related to internationalization of the software:

* International issues can be divided into four groups: native language rules, character sets, I/O formatting, and message translation.
* C++ has broad support for character sets, imposing few minimum requirements.
* At compile time, C++ reads files in the physical character set, and converts the characters to the source character set.
* At runtime, C++ interprets characters according to the execution character set.
* The execution character set comes in two flavors: narrow and wide.
* Narrow characters use the char type. Wide characters use the wchar_t type.
* You have no control over the execution character set. You can only hope that it is a Unicode encoding (UTF-8 for narrow and UTF-32 for wide).
* C++ does not mandate Unicode character sets, but you can specify Unicode code points as universal character names: \uXXXX or \UXXXXXXXX.
* C++ imposes few requirements on wchar_t, but the ideal implementation is a 32-bit value and UTF-32 encoding.
* A multibyte character set uses a sequence of narrow characters to represent a single logical character.
* Multibyte character sets are useful only for converting to and from wide characters.
* Case conversion is hard to do correctly one character at a time. Much better is to convert an entire string at a time. C++ does it one character at a time.
* A locale specifies I/O formatting rules (among other things).
* I/O formatting rules include: thousands separator, decimal point, and the format of negative numbers. I/O streams automatically use the formatting rules of its locale.
* The initial locale is the classic or “C” locale, which implements universally portable formatting rules.
* The user’s preferences are expressed in the default locale, which is locale(”").
* Other named locales are possible, but the C++ standard does not dictate naming rules.
* Each I/O stream can have a distinct locale. Associating a locale with a stream is called imbuing the stream with the locale.
* Many applications use std::locale only to imbue streams or set the global locale.

Link: http://cpphelp.com/learning/ch08-global.html

You can leave a response, or trackback from your own site.

Leave a Reply