Acessing locale information
The following subroutines provide access to information defined in the current locale as determined by the most recent call to the setlocale subroutine:
- localeconv
- Provides access to locale information defined in the LC_MONETARY and LC_NUMERIC categories of the current locale. The localeconv subroutine retrieves information about these categories, places the information in a structure of type lconv as defined in the locale.h file, and returns a pointer to this structure.
- nl_langinfo
- Returns a pointer to a null-terminated string containing information defined in the LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and LC_TIME categories of the current locale.
- rpmatch
- Tests for positive and negative responses, which are specified in the LC_MESSAGES category of the current locale. Responses can be regular expressions, as well as simple strings. The rpmatch subroutine is not an industry-standard subroutine, portable applications should not assume that this subroutine is available.
The localeconv and nl_langinfo subroutines do not provide access to all LC_* categories.
The current locale setting for a category can be obtained by: setlocale
(
Category,
(
char
*)
0
)
.
The return value is a string specifying the current locale for Category.
The following example determines the current locale setting for the LC_CTYPE category:char *ctype_locale; ctype_locale = setlocale(LC_CTYPE, (char*)0);