Ejemplo n.º 1
0
// use cache  !
 HanZi16FontBitMap * PSP_ChineseUtil::getHanZiBitMap ( const HanZi & hanzi )
{
  
   HanZi16FontBitMap *bmp ; 
   HanZi hanziNotUnicode;;
   
   if ( hanzi.isUnicode )
   {
       hanziNotUnicode.ushort = UnicodeToGBK ( hanzi.ushort  );
   }
   else
   {
       hanziNotUnicode.ushort =  hanzi.ushort  ;
   }	
       
   //    printf("unicode is %u,  ASC code is %u\n" , hanzi.ushort ,   hanziNotUnicode.ushort);
   bmp = HanZiCache :: getHanZiBMP ( hanziNotUnicode );
   
   return bmp ;
   
}
Ejemplo n.º 2
0
//将pbuf内的unicode码转为gbk码.
//pbuf:unicode码存储区,同时也是gbk码的输出区.必须小于80个字节.
//代码转换unit code-> GBK
//正点原子@HYW
//CHECK:09/10/30
void 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++]='?';//无法识别的用?代替 
			continue;
		}
		if(code>=0X4E00)//是汉字
		{   								    
			code=UnicodeToGBK(code);//把unicode转换为gb2312 	   
			pbuf[m++]=code>>8;	 
			pbuf[m++]=(u8)code; 
		}else pbuf[m++]='?';//无法识别的用?代替