我知道怎么取拼音码,但不知怎么取五笔码,下面是原码: 函数原型: function HZPY(HZstring: String): Sting; stdcall; exports HZPY name 'HZtoPY'; 参数说明: HZstring:待转换的中文字符串,可夹杂其它ASCII字符。 返回值: 函数返回参数字符串内中文字符拼音码首位字母的大写值及英文字母大写值。 例子: function HZtoPY(HZstring: String): String; stdcall; external 'HZtoPY.dll' name 'HZtoPY'; var PYM: String; PYM := HZtoPY('维生素E'); 字符串PYM的值为:'WSSE'。function GetPYIndexChar(HZchar: String): Char; begin case WORD(HZchar[1]) shl 8 + WORD(HZchar[2]) of $B0A1..$B0C4 : Result := 'A'; $B0C5..$B2C0 : Result := 'B'; $B2C1..$B4ED : Result := 'C'; $B4EE..$B6E9 : Result := 'D'; $B6EA..$B7A1 : Result := 'E'; $B7A2..$B8C0 : Result := 'F'; $B8C1..$B9FD : Result := 'G'; $B9FE..$BBF6 : Result := 'H'; $BBF7..$BFA5 : Result := 'J'; $BFA6..$C0AB : Result := 'K'; $C0AC..$C2E7 : Result := 'L'; $C2E8..$C4C2 : Result := 'M'; $C4C3..$C5B5 : Result := 'N'; $C5B6..$C5BD : Result := 'O'; $C5BE..$C6D9 : Result := 'P'; $C6DA..$C8BA : Result := 'Q'; $C8BB..$C8F5 : Result := 'R'; $C8F6..$CBF9 : Result := 'S'; $CBFA..$CDD9 : Result := 'T'; $CDDA..$CEF3 : Result := 'W'; $CEF4..$D188 : Result := 'X'; $D1B9..$D4D0 : Result := 'Y'; $D4D1..$D7F9 : Result := 'Z'; else Result := Char(0); end; end;function HZPY(HZstring: String): String; stdcall; var PY: String; lsPY: String; i: Integer; begin for i := 1 to Length(Trim(HZstring)) do begin case ByteType(Trim(HZstring), i) of mbSingleByte: lsPY := UpperCase(copy(Trim(HZstring), i, 1)); mbLeadByte: lsPY := GetPyIndexChar(copy(Trim(HZstring), i, 2)); mbTrailByte: lsPY := ''; end; PY := PY + lsPY; end; Result := PY; end;楼主如果知道了怎么取五笔码,希望能给我发个原码过来([email protected]),谢谢!
你知道就说呀,
函数原型:
function HZPY(HZstring: String): Sting; stdcall;
exports
HZPY name 'HZtoPY';
参数说明:
HZstring:待转换的中文字符串,可夹杂其它ASCII字符。
返回值:
函数返回参数字符串内中文字符拼音码首位字母的大写值及英文字母大写值。
例子:
function HZtoPY(HZstring: String): String; stdcall; external 'HZtoPY.dll' name 'HZtoPY';
var
PYM: String;
PYM := HZtoPY('维生素E');
字符串PYM的值为:'WSSE'。function GetPYIndexChar(HZchar: String): Char;
begin
case WORD(HZchar[1]) shl 8 + WORD(HZchar[2]) of
$B0A1..$B0C4 : Result := 'A';
$B0C5..$B2C0 : Result := 'B';
$B2C1..$B4ED : Result := 'C';
$B4EE..$B6E9 : Result := 'D';
$B6EA..$B7A1 : Result := 'E';
$B7A2..$B8C0 : Result := 'F';
$B8C1..$B9FD : Result := 'G';
$B9FE..$BBF6 : Result := 'H';
$BBF7..$BFA5 : Result := 'J';
$BFA6..$C0AB : Result := 'K';
$C0AC..$C2E7 : Result := 'L';
$C2E8..$C4C2 : Result := 'M';
$C4C3..$C5B5 : Result := 'N';
$C5B6..$C5BD : Result := 'O';
$C5BE..$C6D9 : Result := 'P';
$C6DA..$C8BA : Result := 'Q';
$C8BB..$C8F5 : Result := 'R';
$C8F6..$CBF9 : Result := 'S';
$CBFA..$CDD9 : Result := 'T';
$CDDA..$CEF3 : Result := 'W';
$CEF4..$D188 : Result := 'X';
$D1B9..$D4D0 : Result := 'Y';
$D4D1..$D7F9 : Result := 'Z';
else
Result := Char(0);
end;
end;function HZPY(HZstring: String): String; stdcall;
var
PY: String;
lsPY: String;
i: Integer;
begin
for i := 1 to Length(Trim(HZstring)) do
begin
case ByteType(Trim(HZstring), i) of
mbSingleByte:
lsPY := UpperCase(copy(Trim(HZstring), i, 1));
mbLeadByte:
lsPY := GetPyIndexChar(copy(Trim(HZstring), i, 2));
mbTrailByte:
lsPY := '';
end;
PY := PY + lsPY;
end;
Result := PY;
end;楼主如果知道了怎么取五笔码,希望能给我发个原码过来([email protected]),谢谢!