头文件如下:
class CBig5Gby
{
public:
CBig5Gby();
~CBig5Gby(); void Big5togb(unsigned char *d,int l,unsigned char *dout,int *lout);protected:
void Initi();//初始化
unsigned char m_Left;
bool Leftflag;
int BIG5Order[17954];
};
关键就是Big5togb函数,我不知道它的四个参数是什么意思?该怎么调用啊?
class CBig5Gby
{
public:
CBig5Gby();
~CBig5Gby(); void Big5togb(unsigned char *d,int l,unsigned char *dout,int *lout);protected:
void Initi();//初始化
unsigned char m_Left;
bool Leftflag;
int BIG5Order[17954];
};
关键就是Big5togb函数,我不知道它的四个参数是什么意思?该怎么调用啊?
void CBig5Gby::Big5togb(unsigned char *d,int l,unsigned char *dout,int *lout)
{
//连续性
int id=0; if(Leftflag)
{
Leftflag = 0;
// is English 是英文字符
if(m_Left < 161 || d[id] < 64)
{
dout[id] = m_Left;
id++;
}
else//是BIG5的汉字码
{
if(id+1>l)//一般不会出现 l==1
{
m_Left = d[id];
Leftflag = 1;
(*lout) = id;
return;
} dout[id+1] = (BIG5Order[(m_Left - 161)*191 + d[id] -64]>>8)&0xff;
dout[id ] = (BIG5Order[(m_Left - 161)*191 + d[id] -64])&0xff; id += 2;
}
} while(l>=id)
{
// is English 是英文字符0xa1 =161,0x40=64
if(d[id] < 161 || d[id+1] < 64)
{
dout[id] = d[id];
id++;
}
else//是BIG5的汉字码
{
if(id+1>l)
{
m_Left = d[id];
Leftflag = 1;
break;
} dout[id+1] = (BIG5Order[(d[id] - 161)*191 + d[id+1] -64]>>8)&0xff;
dout[id ] = (BIG5Order[(d[id] - 161)*191 + d[id+1] -64])&0xff; id += 2;
}
} (*lout) = id;
}
{
// TODO: Add your control notification handler code here
CBig5Gby convert;
CString cs;
GetDlgItemText(IDC_EDIT1,cs);
unsigned char* c = new unsigned char[cs.GetLength()+1];
unsigned char* c2 = new unsigned char[cs.GetLength()+1];
memcpy(c,cs.GetBuffer(0),cs.GetLength()+1); int m;
convert.Big5togb((unsigned char*)c,cs.GetLength(),(unsigned char*)c2,&m);
CString cs2;
cs2.Format("%s",c2);
SetDlgItemText(IDC_EDIT2,cs2);
}
[email protected]