diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/unicode.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libbb/unicode.c b/libbb/unicode.c index e98cbbf35..acc7cd8df 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -69,8 +69,14 @@ void FAST_FUNC init_unicode(void) | |||
69 | void FAST_FUNC reinit_unicode(const char *LANG) | 69 | void FAST_FUNC reinit_unicode(const char *LANG) |
70 | { | 70 | { |
71 | unicode_status = UNICODE_OFF; | 71 | unicode_status = UNICODE_OFF; |
72 | #if ENABLE_PLATFORM_MINGW32 | ||
73 | /* enable unicode only when ACP is UTF8 and the env var is not 'C' */ | ||
74 | if (GetACP() != CP_UTF8 || (LANG && LANG[0] == 'C' && LANG[1] == 0)) | ||
75 | return; | ||
76 | #else | ||
72 | if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF"))) | 77 | if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF"))) |
73 | return; | 78 | return; |
79 | #endif | ||
74 | unicode_status = UNICODE_ON; | 80 | unicode_status = UNICODE_ON; |
75 | } | 81 | } |
76 | 82 | ||
@@ -270,7 +276,9 @@ int FAST_FUNC iswpunct(wint_t wc) | |||
270 | return (unsigned)wc <= 0x7f && ispunct(wc); | 276 | return (unsigned)wc <= 0x7f && ispunct(wc); |
271 | } | 277 | } |
272 | 278 | ||
279 | #define WCWIDTH_ALT (ENABLE_PLATFORM_MINGW32 && CONFIG_LAST_SUPPORTED_WCHAR >= 0x30000) | ||
273 | 280 | ||
281 | # if !WCWIDTH_ALT || ENABLE_UNICODE_BIDI_SUPPORT | ||
274 | # if CONFIG_LAST_SUPPORTED_WCHAR >= 0x300 | 282 | # if CONFIG_LAST_SUPPORTED_WCHAR >= 0x300 |
275 | struct interval { | 283 | struct interval { |
276 | uint16_t first; | 284 | uint16_t first; |
@@ -327,7 +335,9 @@ static int in_uint16_table(unsigned ucs, const uint16_t *table, unsigned max) | |||
327 | return 0; | 335 | return 0; |
328 | } | 336 | } |
329 | # endif | 337 | # endif |
338 | # endif /* !WCWIDTH_ALT || ENABLE_UNICODE_BIDI_SUPPORT */ | ||
330 | 339 | ||
340 | # if !WCWIDTH_ALT | ||
331 | 341 | ||
332 | /* | 342 | /* |
333 | * This is an implementation of wcwidth() and wcswidth() (defined in | 343 | * This is an implementation of wcwidth() and wcswidth() (defined in |
@@ -697,6 +707,9 @@ int FAST_FUNC wcwidth(unsigned ucs) | |||
697 | # endif /* >= 0x300 */ | 707 | # endif /* >= 0x300 */ |
698 | } | 708 | } |
699 | 709 | ||
710 | # else /* WCWIDTH_ALT */ | ||
711 | # include "wcwidth_alt.c" /* simpler and more up-to-date implementation */ | ||
712 | # endif | ||
700 | 713 | ||
701 | # if ENABLE_UNICODE_BIDI_SUPPORT | 714 | # if ENABLE_UNICODE_BIDI_SUPPORT |
702 | int FAST_FUNC unicode_bidi_isrtl(wint_t wc) | 715 | int FAST_FUNC unicode_bidi_isrtl(wint_t wc) |