function GetHzPy(const AHzStr: string): string;<br>{得到汉字文本的拼音首字母,返回全大写}<br>const<br> ChinaCode: array[0..25, 0..1] of Integer = ((1601, 1636), (1637, 1832), (1833, 2077),<br> (2078, 2273), (2274, 2301), (2302, 2432), (2433, 2593), (2594, 2786), (9999, 0000),<br> (2787, 3105), (3106, 3211), (3212, 3471), (3472, 3634), (3635, 3722), (3723, 3729),<br> (3730, 3857), (3858, 4026), (4027, 4085), (4086, 4389), (4390, 4557), (9999, 0000),<br> (9999, 0000), (4558, 4683), (4684, 4924), (4925, 5248), (5249, 5589));<br>var<br> i, j, HzOrd: Integer;<br>begin<br> Result:='';<br> i := 1;<br> while i <= Length(AHzStr) do<br> begin<br> if (AHzStr >= #160) and (AHzStr[i + 1] >= #160) then<br> begin<br> HzOrd := (Ord(AHzStr) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;<br> for j := 0 to 25 do<br> begin<br> if (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) then<br> begin<br> Result := Result + Char(Byte('A') + j);<br> Break;<br> end;<br> end;<br> Inc(i);<br> end else Result := Result + AHzStr;<br> Inc(i);<br> end;<br>end;