1From f0a4ffb3f6b9128e4c77ec1ff509077feb330298 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 9 Dec 2022 11:15:45 +0800 4Subject: [PATCH 7/8] Support bypassing Unicode when printing 5 6Enabled by default. 7 8Based on: 9https://blog.csdn.net/wavemcu/article/details/7202908 10 11Tested on RK3588 EVB: 121/ Disable CONFIG_UNICODE_SUPPORT 132/ Check busybox ls could display chinese characters 14 15Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 16--- 17 libbb/Config.src | 6 ++++++ 18 libbb/printable_string.c | 6 +++++- 19 libbb/unicode.c | 10 +++++++++- 20 3 files changed, 20 insertions(+), 2 deletions(-) 21 22diff --git a/libbb/Config.src b/libbb/Config.src 23index b980f19..8b833c9 100644 24--- a/libbb/Config.src 25+++ b/libbb/Config.src 26@@ -264,6 +264,12 @@ config UNICODE_SUPPORT 27 Probably by the time when busybox will be fully Unicode-clean, 28 other encodings will be mainly of historic interest. 29 30+config UNICODE_BYPASS 31+ bool "Bypass Unicode when printing" 32+ default y 33+ help 34+ This makes various applets bypass Unicode when printing. 35+ 36 config UNICODE_USING_LOCALE 37 bool "Use libc routines for Unicode (else uses internal ones)" 38 default n 39diff --git a/libbb/printable_string.c b/libbb/printable_string.c 40index a814fd0..3473192 100644 41--- a/libbb/printable_string.c 42+++ b/libbb/printable_string.c 43@@ -42,8 +42,12 @@ const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str) 44 unsigned char c = *d; 45 if (c == '\0') 46 break; 47- if (c < ' ' || c >= 0x7f) 48+ if (c < ' ') 49 *d = '?'; 50+#if !ENABLE_UNICODE_BYPASS 51+ if (c >= 0x7f) 52+ *d = '?'; 53+#endif 54 d++; 55 } 56 if (stats) { 57diff --git a/libbb/unicode.c b/libbb/unicode.c 58index e98cbbf..2f9d0d3 100644 59--- a/libbb/unicode.c 60+++ b/libbb/unicode.c 61@@ -1027,7 +1027,11 @@ static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char 62 while ((int)--width >= 0); 63 break; 64 } 65+#if !ENABLE_UNICODE_BYPASS 66 *d++ = (c >= ' ' && c < 0x7f) ? c : '?'; 67+#else 68+ *d++ = (c >= ' ') ? c : '?'; 69+#endif 70 src++; 71 } 72 *d = '\0'; 73@@ -1035,8 +1039,12 @@ static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char 74 d = dst = xstrndup(src, width); 75 while (*d) { 76 unsigned char c = *d; 77- if (c < ' ' || c >= 0x7f) 78+ if (c < ' ') 79 *d = '?'; 80+#if !ENABLE_UNICODE_BYPASS 81+ if (c >= 0x7f) 82+ *d = '?'; 83+#endif 84 d++; 85 } 86 } 87-- 882.20.1 89 90