1 /* 7.11 Localization <locale.h>
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
7 #ifndef _PDCLIB_LOCALE_H
8 #define _PDCLIB_LOCALE_H _PDCLIB_LOCALE_H
9 #include <_PDCLIB_int.h>
10 _PDCLIB_BEGIN_EXTERN_C
12 #ifndef _PDCLIB_NULL_DEFINED
13 #define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
14 #define NULL _PDCLIB_NULL
17 /* The structure returned by localeconv().
19 The values for *_sep_by_space:
21 1 - if symbol and sign are adjacent, a space seperates them from the value;
22 otherwise a space seperates the symbol from the value
23 2 - if symbol and sign are adjacent, a space seperates them; otherwise a
24 space seperates the sign from the value
26 The values for *_sign_posn:
27 0 - Parentheses surround value and symbol
28 1 - sign precedes value and symbol
29 2 - sign succeeds value and symbol
30 3 - sign immediately precedes symbol
31 4 - sign immediately succeeds symbol
35 char * decimal_point; /* decimal point character */
36 char * thousands_sep; /* character for seperating groups of digits */
37 char * grouping; /* string indicating the size of digit groups */
38 char * mon_decimal_point; /* decimal point for monetary quantities */
39 char * mon_thousands_sep; /* thousands_sep for monetary quantities */
40 char * mon_grouping; /* grouping for monetary quantities */
41 char * positive_sign; /* string indicating nonnegative mty. qty. */
42 char * negative_sign; /* string indicating negative mty. qty. */
43 char * currency_symbol; /* local currency symbol (e.g. '$') */
44 char * int_curr_symbol; /* international currency symbol (e.g. "USD" */
45 char frac_digits; /* fractional digits in local monetary qty. */
46 char p_cs_precedes; /* if currency_symbol precedes positive qty. */
47 char n_cs_precedes; /* if currency_symbol precedes negative qty. */
48 char p_sep_by_space; /* if it is seperated by space from pos. qty. */
49 char n_sep_by_space; /* if it is seperated by space from neg. qty. */
50 char p_sign_posn; /* positioning of positive_sign for mon. qty. */
51 char n_sign_posn; /* positioning of negative_sign for mon. qty. */
52 char int_frac_digits; /* Same as above, for international format */
53 char int_p_cs_precedes; /* Same as above, for international format */
54 char int_n_cs_precedes; /* Same as above, for international format */
55 char int_p_sep_by_space; /* Same as above, for international format */
56 char int_n_sep_by_space; /* Same as above, for international format */
57 char int_p_sign_posn; /* Same as above, for international format */
58 char int_n_sign_posn; /* Same as above, for international format */
61 /* First arguments to setlocale().
62 TODO: Beware, values might change before v0.6 is released.
66 /* Collation (strcoll(), strxfrm()) */
68 /* Character types (<ctype.h>) */
70 /* Monetary formatting (as returned by localeconv) */
72 /* Decimal-point character (for printf() / scanf() functions), string
73 conversions, nonmonetary formatting as returned by localeconv */
75 /* Time formats (strftime(), wcsftime()) */
78 /* The category parameter can be any of the LC_* macros to specify if the call
79 to setlocale() shall affect the entire locale or only a portion thereof.
80 The category locale specifies which locale should be switched to, with "C"
81 being the minimal default locale, and "" being the locale-specific native
82 environment. A NULL pointer makes setlocale() return the *current* setting.
83 Otherwise, returns a pointer to a string associated with the specified
84 category for the new locale.
86 char * setlocale( int category, const char * locale ) _PDCLIB_nothrow;
88 /* Returns a struct lconv initialized to the values appropriate for the current
91 struct lconv * localeconv( void ) _PDCLIB_nothrow;
93 #if _PDCLIB_POSIX_MIN(2008)
94 #define LC_COLLATE_MASK (1 << LC_COLLATE)
95 #define LC_CTYPE_MASK (1 << LC_CTYPE)
96 #define LC_MONETARY_MASK (1 << LC_MONETARY)
97 #define LC_NUMERIC_MASK (1 << LC_NUMERIC)
98 #define LC_TIME_MASK (1 << LC_TIME)
99 #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | \
100 LC_NUMERIC_MASK | LC_TIME_MASK)
103 /* POSIX locale type */
104 typedef _PDCLIB_locale_t locale_t;
107 extern struct _PDCLIB_locale _PDCLIB_global_locale;
108 #define LC_GLOBAL_LOCALE (&_PDCLIB_global_locale)
110 #ifdef _PDCLIB_LOCALE_METHOD
112 locale_t newlocale(int category_mask, const char *locale, locale_t base);
114 /* Set the thread locale to newlocale
116 * If newlocale is (locale_t)0, then doesn't change the locale and just returns
117 * the existing locale.
119 * If newlocale is LC_GLOBAL_LOCALE, resets the thread's locale to use the
122 * Returns the previous thread locale. If the thread had no previous locale,
123 * returns the global locale.
125 locale_t uselocale(locale_t newlocale);
127 /* Returns a copy of loc */
128 locale_t duplocale(locale_t loc);
130 /* Frees the passed locale object */
131 void freelocale(locale_t loc);