Linux busybox Chinese display modification tutorial, linuxbusybox
1. kernel Modification
Go to the kernel and run make menuconfig.
Go
File systems --->
Native language support --->
UTF-8 NLS
Choose NLS UTF-8 to save and exit the compiling kernel.
2. Modify busybox
Modify the two parts in printable_string.c as follows:
while (1) {unsigned char c = *s;if (c == '\0') {/* 99+% of inputs do not need conversion */if (stats) {stats->byte_count = (s - str);stats->unicode_count = (s - str);stats->unicode_width = (s - str);}return str;}if (c < ' ')break;#if 0 //modifyif (c >= 0x7f)break;#endifs++;}
while (1) {unsigned char c = *d;if (c == '\0')break;#if 0 //modifyif (c < ' ' || c >= 0x7f)#elseif (c < ' ')#endif*d = '?';d++;}
The red part is the modified part.
Modifying unicode. c function unicode_conv_to_printable2
if (unicode_status != UNICODE_ON) {char *d;if (flags & UNI_FLAG_PAD) {d = dst = xmalloc(width + 1);while ((int)--width >= 0) {unsigned char c = *src;if (c == '\0') {do*d++ = ' ';while ((int)--width >= 0);break;}#if 0 //modify *d++ = (c >= ' ' && c < 0x7f) ? c : '?';#else*d++ = (c >= ' ') ? c : '?';#endifsrc++;}*d = '\0';} else {d = dst = xstrndup(src, width);while (*d) {unsigned char c = *d;#if 0 //modify if (c < ' ' || c >= 0x7f)#elseif (c < ' ')#endif*d = '?';d++;}}if (stats)stats->byte_count = stats->unicode_count = (d - dst);return dst;}
The red part is the modified part. After modification, recompile busybox.
Add parameters when mounting a File System
Iocharset = utf8
In this way, Chinese characters can be displayed normally on the terminal.