源码如下:说明 函数GetStr 就是取汉字的首拼音。<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..$D1B8 : result := 'X';<br> $D1B9..$D4D0 : result := 'Y';<br> $D4D1..$D7F9 : result := 'Z';<br> else<br> result := char(32);<br> end;<br>end;<br>function GetStr(Chinese:string):string;<br>var<br> I: Integer;<br> PY: string;<br> s: string;<br>begin<br> s := '' ;<br> I := 1;<br> while I <= Length(Chinese) do<br> begin<br> PY := Copy(Chinese, I , 1);<br> if PY >= Chr(128) then<br> begin<br> Inc(I);<br> PY := PY + Copy(Chinese, I , 1);<br> s := s + GetPYIndexChar(PY);<br> end<br> else<br> s := s + PY;<br> Inc(I);<br> end;<br> result := s;<br>end;<br>