aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-07-07 14:41:58 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-07-07 14:41:58 +0200
commitd8f6d8c627155997596cc140fabda88e5e72dc4f (patch)
treef5338ef03968d4d4044a1a61774f38aa48189642 /libbb
parent2301d127a2676303eac563e7932c03d9d72c446e (diff)
downloadbusybox-w32-d8f6d8c627155997596cc140fabda88e5e72dc4f.tar.gz
busybox-w32-d8f6d8c627155997596cc140fabda88e5e72dc4f.tar.bz2
busybox-w32-d8f6d8c627155997596cc140fabda88e5e72dc4f.zip
Call setlocale("") , not "C", if we want to set the default one
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-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");