linux busybox中文显示修改说明

1.内核修改

进入内核,执行make menuconfig后

依次进入
File systems  --->
Native language support  ---> 
NLS UTF-8
选上NLS UTF-8 保存退出编译内核.

2.busybox修改

修改文件printable_string.c中两处,如下:
	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 //modify
		if (c >= 0x7f)
			break;
#endif
		s++;
	}
		while (1) {
			unsigned char c = *d;
			if (c == '\0')
				break;
#if 0 //modify
			if (c < ' ' || c >= 0x7f)
#else
			if (c < ' ')
#endif
				*d = '?';
			d++;
		}
红色部分为修改部分.
修改 unicode.c函数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 : '?';
#endif
				src++;
			}
			*d = '\0';
		} else {
			d = dst = xstrndup(src, width);
			while (*d) {
				unsigned char c = *d;
#if 0 //modify 
				if (c < ' ' || c >= 0x7f)
#else
				if (c < ' ')
#endif
					*d = '?';
				d++;
			}
		}
		if (stats)
			stats->byte_count = stats->unicode_count = (d - dst);
		return dst;
	}
红色部分为修改部分,修改后重新编译busybox.
文件系统执行挂载时加入参数
iocharset=utf8
这样在终端就能正常显示中文,如下图:

======================================
作者:hclydao
http://blog.csdn.net/hclydao
版权没有,但是转载请保留此段声明

===========================================

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值