delphi取汉字的机内代码、UniCode代码
//机内代码-汉字
函数宏代码2字符(ai unicode : integer ) :字符串;
Var
ch、cl : Integer;
比根
ch :=AiUniCode Div 256;
cl :=AiUniCode Mod 256;
result:=chr(ch ) chr ) cl;
结束;
//汉字-机内代码
函数Chinese2maccode (ai Chinese : string ) :集成器;
Var
ch、cl : Integer;
比根
ch:=ord(AIChinese[1] );
cl:=ord(AIChinese[2] );
result:=(chSHL8) cl;
结束;
//UniCode -汉字
函数唯一代码2字符(ai unicode : integer ) :字符串;
Var
ch,cl : String[3];
s:斯特林;
比根
s:=inttohex(AIunicode,2 );
cl:='$'copy(s,1,2 );
ch:='$'copy(s,3,2 );
s:=chr(strtoint(ch ) ) chr (strtoint ) cl ) ) 0;
结果:=widechar tostring (pwidechar (s );
结束;
//汉字- UniCode
函数Chinese2unicode (ai Chinese : string ) :集成器;
Var
ch,cl : String[2];
a : array [1.2] of char;
比根
stringtowidechar (copy (ai Chinese,1,2 ),@ ) @(a[1],2 );
ch:=inttohex(integer(a[2],2 );
cl:=inttohex(integer(a[1],2 );
result:=strtoint('$'chcl;
结束;
//机内代码-汉字
函数宏代码2字符(ai unicode : integer ) :字符串;
Var
ch、cl : Integer;
比根
ch :=AiUniCode Div 256;
cl :=AiUniCode Mod 256;
result:=chr(ch ) chr ) cl;
结束;
//汉字-机内代码
函数Chinese2maccode (ai Chinese : string ) :集成器;
Var
ch、cl : Integer;
比根
ch:=ord(AIChinese[1] );
cl:=ord(AIChinese[2] );
result:=(chSHL8) cl;
结束;
//UniCode -汉字
函数唯一代码2字符(ai unicode : integer ) :字符串;
Var
ch,cl : String[3];
s:斯特林;
比根
s:=inttohex(AIunicode,2 );
cl:='$'copy(s,1,2 );
ch:='$'copy(s,3,2 );
s:=chr(strtoint(ch ) ) chr (strtoint ) cl ) ) 0;
结果:=widechar tostring (pwidechar (s );
结束;
//汉字- UniCode
函数Chinese2unicode (ai Chinese : string ) :集成器;
Var
ch,cl : String[2];
a : array [1.2] of char;
比根
stringtowidechar (copy (ai Chinese,1,2 ),@ ) @(a[1],2 );
ch:=inttohex(integer(a[2],2 );
cl:=inttohex(integer(a[1],2 );
result:=strtoint('$'chcl;
结束;