 RealView Libraries and Floating Point Support Guide |
|
| Selecting locale at link time2.7.1. Selecting locale at link timeThe locale subsystem of the C library can be selected at link time or extended to be selectable at runtime. The following describes the use of locale categories by the library: The default implementation of each locale category is for the C locale. The library also provides an alternative, ISO8859‑1 (Latin‑1 alphabet) implementation of each locale category that you can select at link time. Both the C and ISO8859‑1 default implementations usually provide one locale for each category to select at runtime. You can replace each locale category individually. You can include as many locales in each category as you choose and you can name your locales as you choose. Each locale category uses one word in the private static data of the library. The locale category data is read‑only and position independent. scanf() forces the inclusion of the LC_CTYPE locale category, but in either of the default locales this adds only 260 bytes of read‑only data to several kilobytes of code.
Table 2.7 shows the ISO8859‑1 (Latin‑1 alphabet) locale categories. Table 2.7. Default ISO8859‑1 locales | Symbol | Description |
|---|
__use_iso8859_ctype | Selects the ISO8859‑1 (Latin‑1) classification of characters. This is essentially 7‑bit ASCII, except that the character codes 160‑255 represent a selection of useful European punctuation characters, letters, and accented letters. | __use_iso8859_collate | Selects the strcoll/strxfrm collation table appropriate to the Latin‑1 alphabet. The default C locale does not require a collation table. | __use_iso8859_monetary | Selects the Sterling monetary category using Latin‑1 coding. | __use_iso8859_numeric | Selects separating thousands with commas in the printing of numeric values. | __use_iso8859_locale | Selects all the ISO8859‑1 selections described in this table. |
There is no ISO8859‑1 version of the LC_TIME category. Shift‑JIS and UTF‑8 ImplementationTable 2.8 shows the Shift‑JIS (Japanese characters) or UTF‑8 (Unicode characters) locale categories. Table 2.8. Default Shift‑JIS and UTF‑8 locales | Function | Description |
|---|
__use_sjis_ctype | Sets the character set to the Shift‑JIS multibyte encoding of Japanese characters | __use_utf8_ctype | Sets the character set to the UTF‑8 multibyte encoding of all Unicode characters |
The following describes the effects of Shift‑JIS encoding: The ordinary ctype functions behave correctly on any byte value that is a self‑contained character in Shift‑JIS. For example, half‑width katakana characters, which Shift‑JIS encodes as single bytes between 0xA6 and 0xDF, is treated as alphabetic by isalpha(). The multibyte conversion functions, such as mbrtowc(), mbsrtowcs(), and wcrtomb(), all convert between wide strings in Unicode and multibyte character strings in Shift‑JIS. printf("%ls") converts a Unicode wide string into Shift‑JIS output, and scanf("%ls") converts Shift‑JIS input into a Unicode wide string.
You can arbitrarily switch between multibyte locales and single‑byte locales at runtime if you include more than one in your application. By default, only one locale at a time is included. |
|