發信人: cdsheen.bbs@csie (美麗的故鄉), 信區: sources 標 題: 一個判斷是否為中文字的函式 發信站: 交大資工天龍新聞社(by nbbstin) (Mon Jun 13 02:28:01 1994) 轉信站: cis_nctu!news.cis!news.cc!news.csie!cdsheen // 上次貼了之後 看到沒有什麼人回應 有點灰心 就殺掉了 // 但又有人向我要 就再貼一次了 Sorry. // 本程式由筆者的小 Library 中摘錄下來 /* 若有錯誤 敬請指正 ┌──────┬────┬────┬─────┬──┬────┐ │stdfont.24? │標準字型│ 常用字 │A440-C67E │5401│    │ │(hanstd.24) │    │次常用字│C940-F9D5 │7652│    │ │      │    │ 倚天字 │F9D6-F9FE │ 41│    │ ├──────┼────┼────┼─────┼──┼────┤ │spcfont.24 │特殊符號│ 標準字 │A140-A3BF │ 408│    │ │(han-gr.24) │    │ 控制字 │A3C0-A3E0 │ 33│<- 保留 │ │      │    │ 可造字 │A3E1-A3FE │ 30│<- 保留 │ ├──────┼────┼────┼─────┼──┼────┤ │spcfsupp.24 │特殊字型│    │C6A1-C8FE │ 365│408 max.│ │(han-gr1.24)│    │    │     │*318│Han's 24│ ├──────┼────┼────┼─────┼──┼────┤ │ascfont.24 │ ASCII │    │     │ 256│    │ │(han-asc.24)│    │    │     │  │    │ └──────┴────┴────┴─────┴──┴────┘ */ /* FontInfo 的傳回值 */ #define Font_ASC    1  // 內碼屬 ASCII 範圍 #define Font_STD    2  // 內碼屬標準字型範圍 #define Font_SPC    3  // 內碼屬特殊符號範圍 #define Font_SPCF   4  // 內碼屬特殊字型範圍 #include  unsigned char FontInfo(unsigned char hb,unsigned char lb,long &location)  {   int hadd,ladd;   unsigned int big5;   big5=lb+(hb<<8);   if ( big5>=0xa140 && big5<=0xa3bf )  //spcfont.* 特殊符號 A140-A3BF,408   {    hadd=(hb-161)*157;    ladd=(lb<127)?(lb-64):(lb-161+63);    location=hadd+ladd;    return(Font_SPC);   }   else if ( big5>=0xc6a1 && big5<=0xc8d3 ) //spcfsupp.*   {    hadd=(hb-198)*157-63;    ladd=(lb<127)?(lb-64):(lb-161+63);    location=hadd+ladd;    return(Font_SPCF);   }   else if ( ( lb<=0x7e&&lb>=0x40 || lb<=0xfe&&lb>=0xa1 )&&( big5>=0xa440         && big5<=0xc67e || big5<=0xf9fe && big5>=0xc940 ))   {    hadd=(hb-164)*157;          // Standard Words , 13094    ladd=(lb<127)?(lb-64):(lb-161+63);    location=hadd+ladd;    if(big5>=0xc940) location-=408;    return(Font_STD);   }   else      // Normal ACSII Codes   {    location=hb;    return(Font_ASC);   }  } -- Sheen Cherng-Dar 沈成達 Dep. of Computer Science & Information Eng. National Chiao-Tung University,Hsin-Chu,Taiwan u8117100@cc.nctu.edu.tw,cdsheen@csie.nctu.edu.tw