看这段代码吧(抄来的,修改了一下^_^)<br><br>function GetPYIndexChar( hzchar:string):char;<br>begin<br> case WORD(hzchar[1]) shl 8 + WORD(hzchar[2]) of<br> $B0A1..$B0C4 : result := 'A';<br> $B0C5..$B2C0 : result := 'B';<br> $B2C1..$B4ED : result := 'C';<br> $B4EE..$B6E9 : result := 'D';<br> $B6EA..$B7A1 : result := 'E';<br> $B7A2..$B8C0 : result := 'F';<br> $B8C1..$B9FD : result := 'G';<br> $B9FE..$BBF6 : result := 'H';<br> $BBF7..$BFA5 : result := 'J';<br> $BFA6..$C0AB : result := 'K';<br> $C0AC..$C2E7 : result := 'L';<br> $C2E8..$C4C2 : result := 'M';<br> $C4C3..$C5B5 : result := 'N';<br> $C5B6..$C5BD : result := 'O';<br> $C5BE..$C6D9 : result := 'P';<br> $C6DA..$C8BA : result := 'Q';<br> $C8BB..$C8F5 : result := 'R';<br> $C8F6..$CBF9 : result := 'S';<br> $CBFA..$CDD9 : result := 'T';<br> $CDDA..$CEF3 : result := 'W';<br> $CEF4..$D188 : result := 'X';<br> $D1B9..$D4D0 : result := 'Y';<br> $D4D1..$D7F9 : result := 'Z';<br> else<br> result := char(0);<br> end;<br>end;<br><br>function getPyString(ChString:String);<br>var i, j:integer; Py,hzchar :string;<br>begin<br> Py:='';<br> i:=1;<br> while i<=Length(ChString) do<br> begin<br> hzchar:=ChString+ChString[i+1];<br> Py:=Py+GetPYIndexChar(hzchar);<br> i:=i+2;<br> end;<br> result:=Py;<br>end;<br><br>缺点是不能对付多音字。