線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1338
推到 Plurk!
推到 Facebook!

Delphi中按拼音索引查找漢字

 
jackkcg
站務副站長


發表:891
回覆:1050
積分:848
註冊:2002-03-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-10-04 10:58:53 IP:61.221.xxx.xxx 未訂閱
Delphi中按拼音索引查找漢字 http://www.zdnet.com.cn/developer/code/story/0,2000081534,39054641,00.htm 作者: 萬重 Thursday, September 5 2002 3:24 PM 本文介紹了如何用delphi在指定的字串列表[SourceStrs]中按拼音索引字串符合[PYIndexStr]的所有字串。 function SearchByPYIndex(SourceStrs: TStrings; PYIndexStr: string): string; 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; label NotFound; var I, J: integer; hzchar: string; begin for I := 0 to SourceStrs.Count - 1 do begin for J := 1 to Length(PYIndexStr) do begin hzchar := SourceStrs[2 * J - 1] SourceStrs[2 * J]; if (PYIndexStr[J] <> '?') and (UpperCase(PYIndexStr[J]) <> GetPYIndexChar(hzchar)) then goto NotFound; end; if result = '' then result := SourceStrs // 找到一行 else result := result Char(13) SourceStrs; // 找到多行 NotFound: end; end;
------
**********************************************************
哈哈&兵燹
最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好

Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知
K.表Knowlege 知識,就是本站的標語:Open our mind
系統時間:2024-04-24 6:10:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!