|
本帖最后由 rosynirvana 于 2014-9-29 22:29 编辑
1. 处理code page 936
双字节的代码第一位一定大于等于0x81,注意char可能是有符号的也可能是无符号的,所以要做类型转换
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int i;
- char poem[100] = "34 白日依山尽";
-
- for(i=0; poem[i]; ++i){
- if((unsigned char)poem[i] < 0x81){
- putchar(poem[i]);
- putchar('\n');
- }
- else{
- putchar(poem[i]);
- putchar(poem[++i]);
- putchar('\n');
- }
- }
- system("pause");
- return 0;
- }
复制代码 |
|