//将pbuf内的unicode码转为gbk码.//pbuf:unicode码存储区,同时也是gbk码的输出区.必须小于80个字节.//代码转换unit code-> GBK//发烧友@HYW//CHECK:09/10/30void UniToGB(u8 *pbuf){ unsigned int code;unsigned char i,m=0; for(i=0;i<80;i++)//最长80个字符{ code= pbuf[i*2+1]*256+pbuf[i*2]; if((code==0)||(code==0xffff))break;if((code&0xff00)==0)//字母{if((code>=0x20)&&(code<=0x7e)){pbuf[m++]=(unsigned char)code; }else pbuf[m++]='?';//无法识别的用?代替 con
tinue;}if(code>=0X4E00)//是汉字{ code=UnicodeToGBK(code);//把unicode转换为gb2312 pbuf[m++]=code>>8; pbuf[m++]=(u8)code; }else pbuf[m++]='?';//无法识别的用?代替 } pbuf[m]='