請問有什麼辦法可以查到中文字的部首 |
尚未結案
|
folkchen
高階會員 發表:9 回覆:232 積分:173 註冊:2003-10-09 發送簡訊給我 |
|
folkchen
高階會員 發表:9 回覆:232 積分:173 註冊:2003-10-09 發送簡訊給我 |
有找到範例了,但是我不會Delphi
有人可以幫忙改寫為BCB的嗎 http://delphi.ktop.com.tw/topic.php?topic_id=59607
unit lib; interface uses Windows,Forms, SysUtils,Dialogs,Classes; const bushuCodes:array[0..213] of integer=( $4e00,$4e28,$4e36,$4e3f,$4e59,$4e85,$4e8c,$4ea0,$4eba,$513f, $5165,$516b,$5182,$5196,$51ab,$51e0,$51f5,$5200,$529b,$52f9, $5315,$531a,$5338,$5341,$535c,$5369,$5382,$53b6,$53c8,$53e3, $56d7,$571f,$58eb,$5902,$590a,$5915,$5927,$5973,$5b50,$5b80, $5bf8,$5c0f,$5c22,$5c38,$5c6e,$5c71,$5ddb,$5de5,$5df1,$5dfe, $5e72,$5e7a,$5e7f,$5ef4,$5efe,$5f0b,$5f13,$5f50,$5f61,$5f73, $5fc3,$6208,$6238,$624b,$652f,$6534,$6587,$6597,$65a4,$65b9, $65e0,$65e5,$66f0,$6708,$6728,$6b20,$6b62,$6b79,$6bb3,$6bcb, $6bd4,$6bdb,$6c0f,$6c14,$6c34,$706b,$722a,$7236,$723b,$723f, $7247,$7259,$725b,$72ac,$7384,$7389,$74dc,$74e6,$7518,$751f, $7528,$7530,$758b,$7592,$7676,$767d,$76ae,$76bf,$76ee,$77db, $77e2,$77f3,$793a,$79b8,$79be,$7a74,$7acb,$7af9,$7c73,$7cf8, $7f36,$7f51,$7f8a,$7fbd,$8001,$800c,$8012,$8033,$807f,$8089, $81e3,$81ea,$81f3,$81fc,$820c,$821b,$821f,$826e,$8272,$8278, $864d,$866b,$8840,$884c,$8863,$897e,$898b,$89d2,$8a00,$8c37, $8c46,$8c55,$8c78,$8c9d,$8d64,$8d70,$8db3,$8eab,$8eca,$8f9b, $8fb0,$8fb5,$9091,$9149,$91c6,$91cc,$91d1,$9577,$9580,$961c, $96b6,$96b9,$96e8,$9752,$975e,$9762,$9769,$97cb,$97ed,$97f3, $9801,$98a8,$98db,$98df,$9996,$9999,$99ac,$9aa8,$9ad8,$9adf, $9b25,$9b2f,$9b32,$9b3c,$9b5a,$9ce5,$9e75,$9e7f,$9ea5,$9ebb, $9ec3,$9ecd,$9ed1,$9ef9,$9efd,$9f0e,$9f13,$9f20,$9f3b,$9f4a, $9f52,$9f8d,$9f9c,$9fa0); PenCodes:array[1..30] of integer=( $A440,$A442,$A454,$A4A1,$A4FE,$A5E0,$A6EA,$A8C3,$AB45,$ADBC, $B0AE,$B3C3,$B6C3,$B9AC,$BBF5,$BEA7,$C075,$C24F,$C35F,$C457, $C4D7,$C56B,$C5C8,$C5F1,$C655,$C665,$C66C,$C676,$C679,$C67D); function GetUnicodeWord(str:string):WideString; //將BIG字元轉成UNICODE function GetUnicodeCode(input:WideString):String; //將UNICODE碼 function GetBIG5Code(input:String):String; //取得BIG5碼 function GetWideString(code:integer):WideString; //將UNICODE碼轉成UNICODE字元 function GetWordCount(Str:string):Integer; //取得字數 function Delay(lMilliSeconds: longint):integer; function GetbushuCode(code:integer):WideString; //取得部首 function GetPenCode(code:integer):integer; //取得比畫 implementation function GetUnicodeWord(str:string):WideString; begin result:=Widestring(str); end; function GetbushuCode(code:integer):widestring; var i:integer; begin for i:=0 to 212 do if code>=bushuCodes[i] then if code<=bushuCodes[i 1] then begin result:=Widechar(bushuCodes[i]); exit; end; end; function GetPenCode(code:integer):integer; var i:integer; begin for i:=1 to 30 do if code>=PenCodes[i] then if code<=PenCodes[i 1] then begin result:=i; exit; end; end; function GetBIG5Code(input:String):String; begin result:=inttohex(ord(input[1]),2) inttohex(ord(input[2]),2); end; function GetUnicodeCode(input:WideString):String; var i:integer; output:string; begin output:=''; for i:=1 to length(input) do begin output:=output inttohex(ord(input[i]),4); end; result:=output; end; function GetWideString(code:integer):WideString; var i:integer; begin result:=Widechar(code); end; function GetWordCount(Str:string):Integer; begin result:=length(Str) div 2 end; function Delay(lMilliSeconds: longint):integer; var lStart: longint; begin lStart := GetTickCount; while longint(GetTickCount) - lStart <= lMilliSeconds do Application.ProcessMessages; result:=0; end; end. |
windblown
中階會員 發表:0 回覆:117 積分:98 註冊:2003-11-14 發送簡訊給我 |
我嘗試改成 c++, 不過沒有 BCB 來測試, 可能還需要 include
// code = unicode const int bushuCodes[]={ 0x4e00,0x4e28,0x4e36,0x4e3f,0x4e59,0x4e85,0x4e8c,0x4ea0,0x4eba,0x513f, 0x5165,0x516b,0x5182,0x5196,0x51ab,0x51e0,0x51f5,0x5200,0x529b,0x52f9, 0x5315,0x531a,0x5338,0x5341,0x535c,0x5369,0x5382,0x53b6,0x53c8,0x53e3, 0x56d7,0x571f,0x58eb,0x5902,0x590a,0x5915,0x5927,0x5973,0x5b50,0x5b80, 0x5bf8,0x5c0f,0x5c22,0x5c38,0x5c6e,0x5c71,0x5ddb,0x5de5,0x5df1,0x5dfe, 0x5e72,0x5e7a,0x5e7f,0x5ef4,0x5efe,0x5f0b,0x5f13,0x5f50,0x5f61,0x5f73, 0x5fc3,0x6208,0x6238,0x624b,0x652f,0x6534,0x6587,0x6597,0x65a4,0x65b9, 0x65e0,0x65e5,0x66f0,0x6708,0x6728,0x6b20,0x6b62,0x6b79,0x6bb3,0x6bcb, 0x6bd4,0x6bdb,0x6c0f,0x6c14,0x6c34,0x706b,0x722a,0x7236,0x723b,0x723f, 0x7247,0x7259,0x725b,0x72ac,0x7384,0x7389,0x74dc,0x74e6,0x7518,0x751f, 0x7528,0x7530,0x758b,0x7592,0x7676,0x767d,0x76ae,0x76bf,0x76ee,0x77db, 0x77e2,0x77f3,0x793a,0x79b8,0x79be,0x7a74,0x7acb,0x7af9,0x7c73,0x7cf8, 0x7f36,0x7f51,0x7f8a,0x7fbd,0x8001,0x800c,0x8012,0x8033,0x807f,0x8089, 0x81e3,0x81ea,0x81f3,0x81fc,0x820c,0x821b,0x821f,0x826e,0x8272,0x8278, 0x864d,0x866b,0x8840,0x884c,0x8863,0x897e,0x898b,0x89d2,0x8a00,0x8c37, 0x8c46,0x8c55,0x8c78,0x8c9d,0x8d64,0x8d70,0x8db3,0x8eab,0x8eca,0x8f9b, 0x8fb0,0x8fb5,0x9091,0x9149,0x91c6,0x91cc,0x91d1,0x9577,0x9580,0x961c, 0x96b6,0x96b9,0x96e8,0x9752,0x975e,0x9762,0x9769,0x97cb,0x97ed,0x97f3, 0x9801,0x98a8,0x98db,0x98df,0x9996,0x9999,0x99ac,0x9aa8,0x9ad8,0x9adf, 0x9b25,0x9b2f,0x9b32,0x9b3c,0x9b5a,0x9ce5,0x9e75,0x9e7f,0x9ea5,0x9ebb, 0x9ec3,0x9ecd,0x9ed1,0x9ef9,0x9efd,0x9f0e,0x9f13,0x9f20,0x9f3b,0x9f4a, 0x9f52,0x9f8d,0x9f9c,0x9fa0}; // code=big5 code const int PenCodes[30]={ 0xA440,0xA442,0xA454,0xA4A1,0xA4FE,0xA5E0,0xA6EA,0xA8C3,0xAB45,0xADBC, 0xB0AE,0xB3C3,0xB6C3,0xB9AC,0xBBF5,0xBEA7,0xC075,0xC24F,0xC35F,0xC457, 0xC4D7,0xC56B,0xC5C8,0xC5F1,0xC655,0xC665,0xC66C,0xC676,0xC679,0xC67D}; // 將BIG字元轉成UNICODE WideString GetUnicodeWord(const AnsiString& str); // 將整個字串的 UNICODE 碼轉成 c4d7 這種十六進位的字串 AnsiString GetUnicodeCode(const WideString& input); // 將第一個 big5 字元轉成 BIG5碼 AnsiString GetBIG5Code(const AnsiString& input); WideString GetWideString(int code); //將UNICODE碼轉成UNICODE字元 int GetWordCount(const AnsiString& Str); // 取得字數 int Delay(long lMilliSeconds); WideString GetbushuCode(int code); // 取得部首, code=unicode code int GetPenCode(int code); // 取得比畫, code=big5 code WideString GetUnicodeWord(const AnsiString& str) { return Widestring(str); } WideString GetbushuCode(int code) { // 小於資料表範圍內的時候 if ( code |
folkchen
高階會員 發表:9 回覆:232 積分:173 註冊:2003-10-09 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
folkchen
高階會員 發表:9 回覆:232 積分:173 註冊:2003-10-09 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |