原因在于:KEIL C51 的一个汉字BUG,keil c51在编译的时候会将0xfd的字符(有些汉字含该字符的内码)过滤,
最佳解决方案:打补丁,用 晓奇工作室出的补丁 cckeilvxx.exe
http://www.pc6.com/softview/SoftView_67694.html
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
下面来自网友:http://blog.sina.com.cn/s/blog_6101ed5f0101g6ee.html
1.官方解释
GENERAL: COMPILER IGNORES 0XFD, 0XFE, 0XFF VALUES IN STRINGS
Information in this article applies to:
C166 Compiler All Versions
Cx51 Compiler All Versions
C251 Compiler All Versions
QUESTION
I have a problem with the interpretation of Russian strings in the Keil C51 compiler. Some Russian characters are using the encoding 0xFD. It looks like this encoding is ignored by the compiler and is not included in the program code.
Example:
code char RussianString[] = "??? ????";
Why does this problem exist and how can I avoid this behavior?
ANSWER
The character encodings 0xFD, 0xFE, and 0xFF are used internally by the C compiler. The ANSI standard only requires support for ASCII characters in the range 0x00 - 0x7F.
You may insert these characters by using HEX encodings in the string as follows:
code char RussianString[] = "My Text" "xFD";
A simple text replacement which replaces all 0xFD characters with the string '" "xFD' should do the job.
即遇到无法显示字符时在其后加xFD
如 :unsigned char code s[]="数学"; 改为 unsigned char code s[]="数xFD学"; 即可正常显示
2.修改keil编译器
用WinHex或C32Asm等HEX编辑工具修改C51BIN中的C51.exe和A51.exe
十六进制搜索 80FBFD 改为 80FBFF 即可。
不过不建议使用这种方法,修改编译器后可能会产生某些意想不到的错误。