poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / setlocale.texi
blob11364d3901a959d5f6f5790431efef8e2fd85751
1 @node setlocale
2 @section @code{setlocale}
3 @findex setlocale
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/setlocale.html}
7 Gnulib module: setlocale, setlocale-null
9 Portability problems fixed by Gnulib module @code{setlocale}:
10 @itemize
11 @item
12 On Windows platforms (excluding Cygwin), @code{setlocale(@var{category},NULL)}
13 ignores the environment variables @code{LC_ALL}, @code{@var{category}}, and
14 @code{LANG}.
15 @item
16 On Windows platforms (excluding Cygwin) and Cygwin 1.5.x,
17 @code{setlocale(LC_ALL,@var{name})} succeeds and sets the LC_CTYPE category to
18 @samp{C} when it does not support the encoding, instead of failing.
19 @item
20 On Windows platforms (excluding Cygwin), @code{setlocale} understands different
21 locale names, that are not based on ISO 639 language names and ISO 3166 country
22 names.
23 @item
24 On Android 4.3, which which doesn't have locales, the @code{setlocale} function
25 always fails.  The replacement, however, supports only the locale names
26 @code{"C"} and @code{"POSIX"}.
27 @end itemize
29 Portability problems fixed by Gnulib module @code{setlocale} or @code{setlocale-null}:
30 @itemize
31 @item
32 Invocations of @code{setlocale (..., NULL)} are not multithread-safe on some
33 platforms:
34 musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
35 To make these invocations multithread-safe, you need the Gnulib module
36 @code{setlocale}, or you need to change the code to invoke @code{setlocale_null}
37 or @code{setlocale_null_r} instead.
38 @end itemize
40 Portability problems not fixed by Gnulib:
41 @itemize
42 @item
43 On Cygwin 1.5.x, which doesn't have locales,
44 @code{setlocale(LC_ALL,NULL)} always returns @code{"C"}.
45 @item
46 On Cygwin 1.7.0, only the charset portion of a locale designation is honored.
47 @item
48 On OpenBSD, @code{setlocale(LC_ALL,"")} will only update categories that
49 are deemed appropriate for the @code{LC_ALL} environment value, even if
50 there are other categories set to different values in the environment.
51 In addition any value is accepted for @code{LC_CTYPE}, and so NULL
52 is never returned to indicate a failure to set locale.
53 To verify category values, each category must be set individually
54 with @code{setlocale(LC_COLLATE,"")} etc.
55 @end itemize