function GetHz(qm, wm: Integer): String;
begin
Result := Chr(160+qm)+Chr(160+wm);
end;
procedure GetQWCode(HZ: string; var Q, W: Word);
begin
Q := Byte(HZ[1]) - $A0; 这是区码
W := Byte(HZ[2]) - $A0; 这是位码
end;
function GetHZCode(vHZ: string): string;
//vHZ:一个汉字
//返回区位码字符串,GB2312中没有的字返回0000
var
QM, WM: Integer;
tStr: string;
begin
tStr := '';
QM := Ord(vHZ[1])-160;
WM := Ord(vHZ[2])-160;
if (QM<0) or (WM<0) then
begin
QM := 0;
WM := 0;
end;
if QM <10 then
tStr := '0'+IntToStr(QM)
else
tStr := IntToStr(QM);
if WM < 10 then
tStr := tStr+'0'+IntToStr(WM)
else
tStr := tStr+IntToStr(WM);
GetHZCode := tStr;
end;
(出处:Delphi园地)