diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2023-06-27 14:41:47 +0300 |
---|---|---|
committer | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2023-07-22 09:40:16 +0300 |
commit | 0efc74740ebc0d98af79ba4a5dfa73bfb5db3df0 (patch) | |
tree | c21fd8650e8c197abb317831c1f84e6fcf021f8e /include | |
parent | 4fe7e7cdd0441e9455cc93c17b40a7a96704e61f (diff) | |
download | busybox-w32-0efc74740ebc0d98af79ba4a5dfa73bfb5db3df0.tar.gz busybox-w32-0efc74740ebc0d98af79ba4a5dfa73bfb5db3df0.tar.bz2 busybox-w32-0efc74740ebc0d98af79ba4a5dfa73bfb5db3df0.zip |
win32: support build with FEATURE_UNICODE_SUPPORT
FEATURE_UTF8_MANIFEST enables Unicode args and filenames on Win 10+.
FEATURE_UTF8_INPUT allows the shell prompt to digest correctly
Unicode strings (as UTF8) which are typed or pasted.
This commit adds support for building with FEATURE_UNICODE_SUPPORT
(mostly by supporting 32 bit wchar_t which busybox expects):
- Unicode-aware line-edit - for the most part cursor movement/del
being (UTF8) codepoint-aware rather than assuming that one-byte
equals one-char-on-screen.
- Codepoint-aware operations in some other utils, like rev or wc -c.
- When UNICODE_COMBINING_WCHARS and UNICODE_WIDE_WCHARS are enabled,
some screen-width-aware operations, like with fold, ls, expand, etc.
The busybox Unicode support is incomplete, and even less so with the
builtin libc replacement functions, like wcwidth, which are active
when UNICODE_USING_LOCALE is unset (mingw lacks those functions).
FEATURE_CHECK_UNICODE_IN_ENV should be set so that Unicode is not
hardcoded but rather depends on the ANSI codepage and some env vars:
LC_ALL=C disables Unicode support, else it's enabled if ACP is UTF8.
There's at least one known issue where the tab-completion-prefix-case
is not updated correctly, e.g. ~/desk<tab> completes to ~/desktop/
instead of ~/Desktop/, because the code which handles it exists
only at the non-unicode code paths, but that's not very critical.
That seems to be the only case where mingw-specific code is disabled
when Unicode is enabled, but there could be other unknown issues.
None of the Unicode options is enabled by default, and the next
commit will make it easier to create a build which supports Unicode.
Diffstat (limited to 'include')
-rw-r--r-- | include/mingw.h | 12 | ||||
-rw-r--r-- | include/unicode.h | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h index 232ffadd7..97db2f6a9 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -586,6 +586,18 @@ char *alloc_ext_space(const char *path); | |||
586 | int add_win32_extension(char *p); | 586 | int add_win32_extension(char *p); |
587 | char *file_is_win32_exe(const char *name); | 587 | char *file_is_win32_exe(const char *name); |
588 | 588 | ||
589 | #if ENABLE_UNICODE_SUPPORT | ||
590 | /* | ||
591 | * windows wchar_t is 16 bit, while linux (and busybox expectation) is 32. | ||
592 | * so when (busybox) unicode.h is included, wchar_t is 32 bit. | ||
593 | * Without unicode.h, MINGW_BB_WCHAR_T is busybox wide char (32), | ||
594 | * and wchar_t is Windows wide char (16). | ||
595 | */ | ||
596 | #define MINGW_BB_WCHAR_T uint32_t /* keep in sync with unicode.h */ | ||
597 | |||
598 | MINGW_BB_WCHAR_T *bs_to_slash_u(MINGW_BB_WCHAR_T *p) FAST_FUNC; | ||
599 | #endif | ||
600 | |||
589 | char *bs_to_slash(char *p) FAST_FUNC; | 601 | char *bs_to_slash(char *p) FAST_FUNC; |
590 | void slash_to_bs(char *p) FAST_FUNC; | 602 | void slash_to_bs(char *p) FAST_FUNC; |
591 | size_t remove_cr(char *p, size_t len) FAST_FUNC; | 603 | size_t remove_cr(char *p, size_t len) FAST_FUNC; |
diff --git a/include/unicode.h b/include/unicode.h index 0317a2151..e894f7148 100644 --- a/include/unicode.h +++ b/include/unicode.h | |||
@@ -87,6 +87,21 @@ void reinit_unicode(const char *LANG) FAST_FUNC; | |||
87 | # undef MB_CUR_MAX | 87 | # undef MB_CUR_MAX |
88 | # define MB_CUR_MAX 6 | 88 | # define MB_CUR_MAX 6 |
89 | 89 | ||
90 | #if ENABLE_PLATFORM_MINGW32 | ||
91 | #undef wint_t | ||
92 | #undef mbstate_t | ||
93 | #undef mbstowcs | ||
94 | #undef wcstombs | ||
95 | #undef wcrtomb | ||
96 | #undef iswspace | ||
97 | #undef iswalnum | ||
98 | #undef iswpunct | ||
99 | #undef wcwidth | ||
100 | |||
101 | #undef wchar_t | ||
102 | #define wchar_t uint32_t /* keep in sync with MINGW_BB_WCHAR_T */ | ||
103 | #endif | ||
104 | |||
90 | /* Prevent name collisions */ | 105 | /* Prevent name collisions */ |
91 | # define wint_t bb_wint_t | 106 | # define wint_t bb_wint_t |
92 | # define mbstate_t bb_mbstate_t | 107 | # define mbstate_t bb_mbstate_t |