2 @section @code{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}:
12 On Windows platforms (excluding Cygwin), @code{setlocale(@var{category},NULL)}
13 ignores the environment variables @code{LC_ALL}, @code{@var{category}}, and
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.
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
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"}.
29 Portability problems fixed by Gnulib module @code{setlocale} or @code{setlocale-null}:
32 Invocations of @code{setlocale (..., NULL)} are not multithread-safe on some
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.
40 Portability problems not fixed by Gnulib:
43 On Cygwin 1.5.x, which doesn't have locales,
44 @code{setlocale(LC_ALL,NULL)} always returns @code{"C"}.
46 On Cygwin 1.7.0, only the charset portion of a locale designation is honored.
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.