⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gb18030.c

📁 其中包含了GB18030的16*16的点阵字库和算法
💻 C
字号:
addr = CountZkAdr(bm1,bm2,bm3,bm4);
//////////////////////////////////////////////////////////////////////////函数:CountZkAdr(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4)//功能:计算汉字点阵在芯片中的地址//参数:c1,c2,c3,c4:4字节汉字内码通过参数c1,c2,c3,c4传入,双字节内码通过参数c1,c2传入,c3=0,c4=0//返回:汉字点阵的字节地址(byte address)。如果用户是按 word mode 读取点阵数据,则其地址(word//address)为字节地址除以2,即:word address = byte address / 2 .//例如:“啊”字的内码为0xb0a1,则byte address = g(0xb0,0xa1,0x00,0x00) *32+0xa7700//word address = byte address / 2//“ ”字的内码为0x8139ee39,则byte address = g(0x81,0x39,0xee,0x39) *32+0xa7700//word address = byte address / 2//说明:在以上计算字节地址中byte address = g(0xb0,0xa1,0x00,0x00) *32+0xa7700的0xa7700是15X16//点阵字库相对整个字库芯片0000 0000的偏移地址/////////////////////////////////////////////////////////////////////////////unsigned int CountZkAdr(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4){	unsigned int h;	if(c1 >= 0xb0 && c2 >= 0xA1 && c3 == 0 && c4 == 0)//汉字2区	B0A1 --- F7FE  0xAF8C0	{		return (unsigned int)((c1-0xB0)*94+(c2-0xA1))*32+0xAF8C0;	}	else if(c1 >= 0xAA && c2 >= 0x40 && c3 == 0 && c4 == 0)//16点阵4区汉字		AA40 --- FEAE  0x113EC0	{		if(c2>0x7f)c2--;		if(c2 > 0xA0)	c2 = 0x40;		return (unsigned int)((c1-0xAA)*96+(c2-0x40))*32+0x113EC0;	}	else if(c1 >= 0xA8 && c3 == 0 && c4 == 0)//字符5区	A840 --- A996  0xAE0C0	{		if(c1>=0xA8 && c2>=0xA1);		else if(c2>0x7f)c2--;		if(c2>=0xA1)			return (unsigned int)((c1-0xA1)*94+(c2-0xA1))*32+0xA7700;		else			return (unsigned int)((c1-0xA8)*96+(c2-0x40))*32+0xAE0C0;	}	else if(c1 >= 0xA1 && c3 == 0 && c4 == 0)//字符1区	A1A1 --- A9FE  0xA7700	{		return (unsigned int)((c1-0xA1)*94+(c2-0xA1))*32+0xA7700;	}	else if(c1 >= 0x81 && c3 == 0 && c4 == 0)//汉字3区	8140 --- A0FE  0xE46C0	{		if(c2>0x7f)c2--;		return (unsigned int)((c1-0x81)*190+(c2-0x40))*32+0xE46C0;	}	else if(c2>=0x30)//汉字4区	{//	four bytes HZ		h=(((unsigned int)(c1-0x81)*10+(c2-0x30))*126+(unsigned int)(c3-0x81))*10+(c4-0x30);		h-=12439;		//if(h<0 || h>=6530) return(0);		if(h>=6530) return(0);		h += 22046;		return h*32+0xA7700;	}	return 0;}//字节倒序  eg: D7....D0 H--->L 转换后为 L -->H D0....D7unsigned char ByteReverseOrder(unsigned char dbyte){	unsigned char i,buff;	buff=0;	for(i=0;i<8;i++)	{		buff<<=1;		buff|=(dbyte>>i)&0x01;	}	return buff;}//进行8×8点矩阵转换  ConIn 要进行转换的数据指针  ConOut 转换后的数据指针void ByteConversion_8(unsigned char *ConIn,unsigned char *ConOut){	unsigned char i,j;//	memcpy(ConOut,ConIn,8);	for(i=0;i<8;i++)	{		ConOut[i]=0;		for(j=0;j<8;j++)		{			ConOut[i]<<=1;			ConOut[i]|=(ByteReverseOrder(ConIn[j])>>(7-i))&0x01;		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -