怎样得到汉字的第一个汉语拼音字母!(200分)

  • 主题发起人 主题发起人 zch619
  • 开始时间 开始时间
Z

zch619

Unregistered / Unconfirmed
GUEST, unregistred user!
如“中华人民共和国”->“ZHRMGHG”,怎样才能做到呀?请高手帮忙呀!
 
源码如下:说明 函数GetStr 就是取汉字的首拼音。<br>function GetPYIndexChar( hzchar:string):char;<br>begin<br>&nbsp; case WORD(hzchar[1]) shl 8 + WORD(hzchar[2]) of<br>&nbsp; &nbsp; $B0A1..$B0C4 : result := 'A';<br>&nbsp; &nbsp; $B0C5..$B2C0 : result := 'B';<br>&nbsp; &nbsp; $B2C1..$B4ED : result := 'C';<br>&nbsp; &nbsp; $B4EE..$B6E9 : result := 'D';<br>&nbsp; &nbsp; $B6EA..$B7A1 : result := 'E';<br>&nbsp; &nbsp; $B7A2..$B8C0 : result := 'F';<br>&nbsp; &nbsp; $B8C1..$B9FD : result := 'G';<br>&nbsp; &nbsp; $B9FE..$BBF6 : result := 'H';<br>&nbsp; &nbsp; $BBF7..$BFA5 : result := 'J';<br>&nbsp; &nbsp; $BFA6..$C0AB : result := 'K';<br>&nbsp; &nbsp; $C0AC..$C2E7 : result := 'L';<br>&nbsp; &nbsp; $C2E8..$C4C2 : result := 'M';<br>&nbsp; &nbsp; $C4C3..$C5B5 : result := 'N';<br>&nbsp; &nbsp; $C5B6..$C5BD : result := 'O';<br>&nbsp; &nbsp; $C5BE..$C6D9 : result := 'P';<br>&nbsp; &nbsp; $C6DA..$C8BA : result := 'Q';<br>&nbsp; &nbsp; $C8BB..$C8F5 : result := 'R';<br>&nbsp; &nbsp; $C8F6..$CBF9 : result := 'S';<br>&nbsp; &nbsp; $CBFA..$CDD9 : result := 'T';<br>&nbsp; &nbsp; $CDDA..$CEF3 : result := 'W';<br>&nbsp; &nbsp; $CEF4..$D1B8 : result := 'X';<br>&nbsp; &nbsp; $D1B9..$D4D0 : result := 'Y';<br>&nbsp; &nbsp; $D4D1..$D7F9 : result := 'Z';<br>&nbsp; else<br>&nbsp; &nbsp; result := char(32);<br>&nbsp; end;<br>end;<br>function GetStr(Chinese:string):string;<br>var<br>&nbsp; I: Integer;<br>&nbsp; PY: string;<br>&nbsp; s: string;<br>begin<br>&nbsp; s := '' ;<br>&nbsp; I := 1;<br>&nbsp; while I &lt;= Length(Chinese) do<br>&nbsp; begin<br>&nbsp; &nbsp; PY := Copy(Chinese, I , 1);<br>&nbsp; &nbsp; if PY &gt;= Chr(128) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Inc(I);<br>&nbsp; &nbsp; &nbsp; PY := PY + Copy(Chinese, I , 1);<br>&nbsp; &nbsp; &nbsp; s := s + GetPYIndexChar(PY);<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; s := s + PY;<br>&nbsp; &nbsp; Inc(I);<br>&nbsp; end;<br>&nbsp; result := s;<br>end;<br>
 
可是如果第一个是数字,怎么办?
 
数字我可以判定一下的,谢谢fly_hong_924了。
 
楼上的函数可以搞定。
 
同音字怎么办?<br>例如:翟
 
鑫<br>这个字怎么没有啊?
 
学习学习!
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2147207
 
谢谢各位!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
700
import
I
后退
顶部