3 <<setlocale>>, <<localeconv>>---select or query locale
16 char *setlocale(int <[category]>, const char *<[locale]>);
17 lconv *localeconv(void);
19 char *_setlocale_r(void *<[reent]>,
20 int <[category]>, const char *<[locale]>);
21 lconv *_localeconv_r(void *<[reent]>);
25 char *setlocale(<[category]>, <[locale]>)
31 char *_setlocale_r(<[reent]>, <[category]>, <[locale]>)
36 lconv *_localeconv_r(<[reent]>);
40 <<setlocale>> is the facility defined by ANSI C to condition the
41 execution environment for international collating and formatting
42 information; <<localeconv>> reports on the settings of the current
45 This is a minimal implementation, supporting only the required <<``C''>>
46 value for <[locale]>; strings representing other locales are not
47 honored unless MB_CAPABLE is defined in which case three new
48 extensions are allowed for LC_CTYPE only: <<''C-JIS''>>, <<''C-EUCJP''>>,
49 and <<''C-SJIS''>>. (<<``''>> is also accepted; it represents the default locale
50 for an implementation, here equivalent to <<``C''>>.)
52 If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
53 a pointer to the string representing the current locale (always
54 <<``C''>> in this implementation). The acceptable values for
55 <[category]> are defined in `<<locale.h>>' as macros beginning with
56 <<"LC_">>, but this implementation does not check the values you pass
57 in the <[category]> argument.
59 <<localeconv>> returns a pointer to a structure (also defined in
60 `<<locale.h>>') describing the locale-specific conventions currently
63 <<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
64 <<localeconv>> and <<setlocale>> respectively. The extra argument
65 <[reent]> is a pointer to a reentrancy structure.
68 <<setlocale>> returns either a pointer to a string naming the locale
69 currently in effect (always <<``C''>> for this implementation, or, if
70 the locale request cannot be honored, <<NULL>>.
72 <<localeconv>> returns a pointer to a structure of type <<lconv>>,
73 which describes the formatting and collating conventions in effect (in
74 this implementation, always those of the C locale).
77 ANSI C requires <<setlocale>>, but the only locale required across all
78 implementations is the C locale.
80 No supporting OS subroutines are required.
84 * setlocale, localeconv : internationalize your locale.
85 * (Only "C" or null supported).
94 int __declspec(dllexport) __mb_cur_max = 1;
99 static _CONST struct lconv lconv =
101 ".", "", "", "", "", "", "", "", "", "",
102 CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
103 CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
108 _DEFUN(_setlocale_r, (p, category, locale),
109 struct _reent *p _AND
116 if (strcmp (locale, "C") && strcmp (locale, ""))
118 p->_current_category = category;
119 p->_current_locale = locale;
123 static char lc_ctype[8] = "C";
124 static char last_lc_ctype[8] = "C";
128 if (category != LC_CTYPE)
130 if (strcmp (locale, "C") && strcmp (locale, ""))
132 if (category == LC_ALL)
134 strcpy (last_lc_ctype, lc_ctype);
135 strcpy (lc_ctype, locale);
141 if (strcmp (locale, "C") && strcmp (locale, "") &&
142 strcmp (locale, "C") && strcmp (locale, "C-JIS") &&
143 strcmp (locale, "C-EUCJP") && strcmp (locale, "C-SJIS") &&
144 strcmp (locale, "UTF-8"))
147 strcpy (last_lc_ctype, lc_ctype);
148 strcpy (lc_ctype, locale);
150 if (!strcmp (locale, "UTF-8"))
152 else if (!strcmp (locale, "C-JIS"))
154 else if (strlen (locale) > 1)
159 p->_current_category = category;
160 p->_current_locale = locale;
162 if (category == LC_CTYPE)
163 return last_lc_ctype;
167 if (category == LC_CTYPE)
178 _DEFUN(_localeconv_r, (data),
181 return (struct lconv *) &lconv;
187 _DEFUN(setlocale, (category, locale),
191 return _setlocale_r (_REENT, category, locale);
196 _DEFUN_VOID(localeconv)
198 return _localeconv_r (_REENT);