Datasheet
The C and C++ Libraries
4-28 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
4.6.2 Selecting locale at run time
The C library function
setlocale()
selects a locale at runtime for the locale category, or
categories, specified in its arguments. It does this by selecting the requested locale
separately in each locale category. In effect, each locale category is a small filing system
containing an entry for each locale.
Each locale category is processed by a function like
_get_lc_category
, for example:
void const *_get_lc_time (void *null, char const *locale_name)
_get_lc_time()
returns the address of the
time
filing system entry for the locale named
locale_name
, or
NULL
if the entry was not found.
The implementation of each locale category must supply a selection function as shown
in Table 4-7.
C header files describing what must be implemented, and providing some useful
support macros, are given in
locale.h
and
rt_locale.h
.
Implementation
For each category, changing locale is achieved by changing a pointer into the read-only
data for the locale category. Except for default locales, the data must be user-supplied.
Table 4-7 Locale categories
Function Description
_get_lc_ctype()
Returns a pointer to the first element in a user-defined array
that holds character attributes. See _get_lc_ctype() on
page 4-30.
_get_lc_collate()
Returns a pointer to the first element in a user-defined array
that holds sorting attributes. See _get_lc_collate() on
page 4-32.
_get_lc_monetary()
Returns a pointer to the user-defined
__lc_monetary_blk
structure. See _get_lc_monetary() on page 4-35.
_get_lc_numeric()
Returns a pointer to the user-defined
__lc_numeric_blk
structure. See _get_lc_numeric() on page 4-37.
_get_lc_time()
Returns a pointer to the user-defined
__lc_time_blk
structure.
See _get_lc_time() on page 4-38.