aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/unicode.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libbb/unicode.c b/libbb/unicode.c
index 35e88d307..2e5dd5adc 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -28,8 +28,19 @@ void FAST_FUNC reinit_unicode(const char *LANG)
28 static const char unicode_0x394[] = { 0xce, 0x94, 0 }; 28 static const char unicode_0x394[] = { 0xce, 0x94, 0 };
29 size_t width; 29 size_t width;
30 30
31 /* We pass "" instead of "C" because some libc's have
32 * non-ASCII default locale for setlocale("") call
33 * (this allows users of such libc to have Unicoded
34 * system without having to mess with env).
35 *
36 * We set LC_CTYPE because (a) we may be called with $LC_CTYPE
37 * value in LANG, not with $LC_ALL, (b) internationalized
38 * LC_NUMERIC and LC_TIME are more PITA than benefit
39 * (for one, some utilities have hard time with comma
40 * used as a fractional separator).
41 */
31//TODO: avoid repeated calls by caching last string? 42//TODO: avoid repeated calls by caching last string?
32 setlocale(LC_ALL, (LANG && LANG[0]) ? LANG : "C"); 43 setlocale(LC_CTYPE, LANG ? LANG : "");
33 44
34 /* In unicode, this is a one character string */ 45 /* In unicode, this is a one character string */
35// can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused 46// can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused
@@ -42,8 +53,6 @@ void FAST_FUNC init_unicode(void)
42 /* Some people set only $LC_CTYPE, not $LC_ALL, because they want 53 /* Some people set only $LC_CTYPE, not $LC_ALL, because they want
43 * only Unicode to be activated on their system, not the whole 54 * only Unicode to be activated on their system, not the whole
44 * shebang of wrong decimal points, strange date formats and so on. 55 * shebang of wrong decimal points, strange date formats and so on.
45 *
46 * TODO? Maybe we should use LC_CTYPE instead of LC_ALL in setlocale()?
47 */ 56 */
48 if (unicode_status == UNICODE_UNKNOWN) { 57 if (unicode_status == UNICODE_UNKNOWN) {
49 char *s = getenv("LC_ALL"); 58 char *s = getenv("LC_ALL");