Chapter Contents

Previous

Next
Localization

Locales and Categories

SAS/C defines the following locales:
"S370" is a locale that defines conventions traditionally associated with the 370 mainframe environment.
"POSIX" is a locale that defines conventions traditionally associated with UNIX implementations, as codified by the POSIX 1003.2 standard.
"C" is the locale in effect when your program begins execution. For programs called with exec linkage, this is the same as the "POSIX" locale. For other programs, it is the same as the "S370" locale.
"" is a locale that represents the best fit for local customs. The "" locale interpretation is controlled by several environment variable settings. See the setlocale function description for more information.

Three other locales are supplied by the SAS/C Library. For details on these locales, see Library-Supplied Locales. As mentioned earlier, you can also supply your own locales; see User-Added Locales for details. A locale is divided into categories, which define different parts of the whole locale. You can change one category without having to change the entire locale. For example, you can change the way currency is displayed without changing the expression of dates and time. The categories of locale defined in <locale.h> are as follows:
LC_ALL affects all the categories at once.
LC_COLLATE affects the collating sequence. This changes how strcoll and strxfrm work.
LC_CTYPE affects how the character type macros (such as isgraph ) work. LC_CTYPE also affects the multibyte functions (such as mblen and wcstombs ) as well as the treatment of multibyte characters by the formatted I/O functions (such as printf and sprintf ) and the string functions.

isdigit and isxdigit are not affected by LC_CTYPE .

LC_MONETARY affects how currency values are formatted.
LC_NUMERIC affects the character used for the decimal point.
LC_TIME affects how strftime formats time values. This category does not affect the behavior of asctime .


The Locale Structure lconv

<locale.h> defines the structure struct lconv . The standard members of this structure are explained in the following list. The default "C" locale values, as defined by the ANSI and ISO C standards, are in parentheses after the descriptions. A default value of CHAR_MAX indicates the information is not available.

char *decimal_point
is the decimal point character used in nonmonetary values. ( "." )

char *thousands_sep
is the character that separates groups of digits to the left of the decimal point in nonmonetary values. ( "" )

char *grouping
is the string whose elements indicate the size of each group of digits in nonmonetary values. ( "" )

char *int_curr_symbol
is the international currency symbol that applies to the current locale. The fourth character, immediately before the null character, is the character used to separate the international currency symbol from the value. ( "" )

char *currency_symbol
is the local currency symbol that applies to the current locale. ( "" )

char *mon_decimal_point
is the decimal point used in monetary values. ( "" )

char *mon_thousands_sep
is the character that separates groups of digits to the left of the decimal point in monetary values. ( "" )

char *mon_grouping
is the string whose elements indicate the size of each group of digits in monetary values. ( "" )

char *positive_sign
is the string that indicates a nonnegative monetary value. ( "" )

char *negative_sign
is the string that indicates a negative monetary value. ( "" )

char int_frac_digits
is the number of fractional digits to be displayed in an internationally-formatted monetary value. ( CHAR_MAX )

char frac_digits
is the number of fractional digits to be displayed in a locally-formatted monetary value. ( CHAR_MAX )

char p_cs_precedes
is set to 1 if the currency_symbol and a nonnegative monetary value are separated by a space, otherwise it is set to 0 . ( CHAR_MAX )

char p_sep_by_space
is set to 1 if the currency_symbol comes before a nonnegative monetary value; it is set to 0 if the currency_symbol comes after the value. ( CHAR_MAX )

char n_cs_precedes
is set to 1 if the currency_symbol and a negative monetary value are separated by a space, otherwise it is set to 0 . ( CHAR_MAX )

char n_sep_by_space
is set to 1 if the currency_symbol comes before a negative monetary value; it is set to 0 if the currency_symbol comes after the value. ( CHAR_MAX )

char p_sign_posn
is set to a value indicating the position of the positive_sign for a nonnegative monetary value. ( CHAR_MAX )

char n_sign_posn
is set to a value indicating the position of the negative_sign for a negative monetary value. ( CHAR_MAX )

The elements of grouping and mon_grouping are defined by the following values:
CHAR_MAX indicates no more grouping is to be done. CHAR_MAX is defined in <limits.h> as 255 .
0 indicates that the previous element is to be repeatedly used for the rest of the digits.
other is the number of digits that make up the current group. The next element is examined to determine the size of the next group to the left.

The value of p_sign_posn and n_sign_posn is defined by the following:
0 indicates that parentheses surround the value and currency_symbol .
1 indicates that the sign comes before the value and currency_symbol .
2 indicates that the sign comes after the value and currency_symbol .
3 indicates that the sign comes immediately before the currency_symbol .
4 indicates that the sign comes immediately after the currency_symbol .


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.