这样改的太多了,想了个办法,将字母和数字的区位码单独放到数组里,然后判断输入的与0xA0作比较,大于的就是汉字输入,否则是字母或数字,再从数组里拿取相应的区位码,去读取字模,但是发送数字结果正确,而无论输入什么汉字,都显示的是“烫”,搞不懂了~
void CMSComDlg::ReadDataFromFile()
{
unsigned char num[2][10] = {
{0xA3,0xA3,0xA3,0xA3,0xA3,0xA3,0xA3,0xA3,0xA3,0xA3}, //0~9的区位码
{0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9}
};
char *p = m_strSendData.GetBuffer(m_strSendData.GetLength()); //输入字符的存储区域
unsigned char i=0, j=0;
unsigned char n,qh,wh;
unsigned long offset;
FILE *fd;
fd=fopen( "HZK16 ", "rb ");
memset(cBuf, 0, 1024);
while(p[i])
for(j = 0; j < m_strSendData.GetLength()/2; j++) //getlength返回字节数
{
if (p[i] <=0xA0) //小于0xA0,输入的是数字
{
i++;
n = p[i++] - '0';
qh =num[0][n] - 0xA0;
wh =num[1][n] - 0xA0;
}
else { //否则是汉字
qh=p[i++]-0xa0;
wh=p[i++]-0xa0;
}