Index: libc/locale/locale.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v retrieving revision 1.46 diff -u -r1.46 locale.c --- libc/locale/locale.c 11 May 2010 20:40:14 -0000 1.46 +++ libc/locale/locale.c 9 Nov 2010 21:05:31 -0000 @@ -845,16 +845,19 @@ __wctomb = l_wctomb; __mbtowc = l_mbtowc; __set_ctype (charset); - /* Check for the language part of the locale specifier. In case - of "ja", "ko", or "zh", assume the use of CJK fonts, unless the - "@cjknarrow" modifier has been specifed. - The result is stored in lc_ctype_cjk_lang and tested in wcwidth() - to figure out the width to return (1 or 2) for the "CJK Ambiguous - Width" category of characters. */ + /* Determine the width for the "CJK Ambiguous Width" category of + characters. This is used in wcwidth(). + Assume single width for single-byte charsets, and double width for + multi-byte charsets other than UTF-8. For UTF-8, use double width for + the East Asian locales ("ja", "ko", "zh"), and single width for + everything else. Single width can also be forced with the + "@cjknarrow" modifier. */ lc_ctype_cjk_lang = !cjknarrow - && ((strncmp (locale, "ja", 2) == 0 + && mbc_max > 1 + && (charset[0] != 'U' + || strncmp (locale, "ja", 2) == 0 || strncmp (locale, "ko", 2) == 0 - || strncmp (locale, "zh", 2) == 0)); + || strncmp (locale, "zh", 2) == 0); #ifdef __HAVE_LOCALE_INFO__ ret = __ctype_load_locale (locale, (void *) l_wctomb, charset, mbc_max); #endif /* __HAVE_LOCALE_INFO__ */