怎样从已知区位码转换到汉字?急!!!(200分)

  • 主题发起人 主题发起人 zhixding
  • 开始时间 开始时间
Z

zhixding

Unregistered / Unconfirmed
GUEST, unregistred user!
DELPHI 程序中:<br>&nbsp;1、象在知道ASCI码102时,用char(102)可得出字符‘f’。<br>&nbsp;2、已确知汉字区位码b5e7(电),怎样编程中得出该汉字?<br><br>&nbsp; 请大侠赐教。
 
恐怕要做个映射表了
 
打开汉字库文件,用b5e7找到对应的字模,用画笔或画点将其显示出来!<br>字模从ccdos/ucdos下拷贝一个.
 
以下代码行吗?<br>procedure TForm1.Label1Click(Sender: TObject);<br>var<br>&nbsp; &nbsp; lnqw,lnqu,lnwei:integer;<br>begin<br>&nbsp; &nbsp; lnqw:=$b5e7;<br>&nbsp; &nbsp; lnwei:=lnqw and $ff;<br>&nbsp; &nbsp; lnqu:=lnqw shr 8;<br>&nbsp; &nbsp; label1.Caption:=char( lnqu )+ char( lnwei );<br>end;<br>
 
我在vc下做过,我删了一些你不用的辅助语句,控制窗口,输入,更新的,之后没又调试<br>但大致就是这个思路,你改一改吧。<br>&nbsp;char Buf[32];//16*16:32;24*24:72;48*48:288<br><br>&nbsp; &nbsp; Addr=((Q-1)*94+W-1)*32;//16*16:32;24*24:72; 48*48:288与点阵大小有关<br>&nbsp; &nbsp; if(Addr&lt;0) return;<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CFile fileword; <br>&nbsp; &nbsp; &nbsp; &nbsp; flag=fileword.Open("hzk16",CFile::modeRead);//换字库名<br>&nbsp; &nbsp; &nbsp; &nbsp; if(flag==0) MessageBox("没能打开字库");<br>&nbsp; &nbsp; &nbsp; &nbsp;else{<br> &nbsp;fileword.Seek(Addr,CFile::begin);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileword.Read(Buf,32*sizeof(char));//16*16:32;24*24:72; 48*48:288;<br> }//读出点阵信息<br>&nbsp; //按点画字 &nbsp; <br>&nbsp; &nbsp; CDC* pDC=GetDC();<br>&nbsp; //CSizeSetViewportExt();...设制显示窗口<br>&nbsp; for(i1=0;i1&lt;16;i1++) //根据字模信息显示汉字16*16:16;24*24:24<br>&nbsp; &nbsp; &nbsp;for(i2=0;i2&lt;2;i2++)//16*16:i2&lt;2; 24*24:i2&lt;3; 48*48:i2&lt;6<br>&nbsp; &nbsp; &nbsp; &nbsp;for(i3=0;i3&lt;8;i3++)/*i1*2+i2字节的第7-i3位等于1则画点*/<br> &nbsp; {//16*16:<br> &nbsp; &nbsp; &nbsp; pDC-&gt;SetPixel(x+i2*8+i3,y+i1,RGB(0,0,238))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//24*24:pDC-&gt;SetPixel(x+i1,y+i2*8+i3,RGB(0,0,255)) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //48*48:同24*24<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
 
简单<br>b5=181<br>e7=231<br>chr(181)+chr(231)='电'<br>
 
太简单了,hwave说的完全正确。<br>字库的办法当然可以,但是太麻烦了。
 
区位码就是俩Ascii码,分别写出俩Ascii码<br>用String的加不就得了
 
首先:<br>注意区位码和机内码的区别,<br>然后是编码方式.<br><br>GB2312 是87区,每区94字.<br>如果是GB2312 ,B5E7肯定是机内码,不是区位码.<br><br>对于GB2312编码<br>区码小于88<br>位码小于95<br><br>GBK 向下兼容GB2312.<br><br>
 
多人接受答案了。
 
后退
顶部