枚举BIG5中的汉字

//Build: gcc -g big5.c -o big5.exe

//

//0xa140 to 0xa3bf          "Graphical characters" 圖形碼

//0xa3c0 to 0xa3fe          Reserved for user-defined characters 造字

//0xa440 to 0xc67e          Frequently used characters 常用字

//0xc6a1 to 0xc8fe          Reserved for user-defined characters

//0xc940 to 0xf9d5          Less frequently used characters 次常用字

//0xf9d6 to 0xfefe          Reserved for user-defined characters

//First byte ("lead byte")      0xa1 to 0xfe

//Second byte          0x40 to 0x7e, 0xa1 to 0xfe

//

//

#include <stdio.h>

 

static void DumpRange(FILE* fp, unsigned short start, unsigned short end)

{

         unsigned char cHigh = 0;

         unsigned char cLow = 0;

         unsigned short i = 0;

        

         for(i = start ; i < end; i++)

         {

                   cHighi >> 8;

                   cLow  =  i & 0xFF;

                  if((cLow >= 0x40 && cLow <= 0x7e) || (cLow >= 0xa1 && cLow <= 0xfe))

                   {

                            fwrite(&cHigh, sizeof(cHigh), 1, fp);

                            fwrite(&cLow, sizeof(cLow), 1, fp);

                   }

         }

         fflush(fp);

 

         return;

}

 

static void DumpBIG5(void)

{

         unsigned short i = 0;

         FILE* fp = fopen("big5.txt", "wb+");

        

         if(fp != NULL)

         {

                  DumpRange(fp, 0xa140, 0xa3bf);

                  DumpRange(fp, 0xa440, 0xc67e);

                  DumpRange(fp, 0xc940, 0xf9d5);

                  

                  fclose(fp);

         }

         else

         {

                  perror("fopen");

         }

 

         return;      

}

 

int main(int argc, char* argv[])

{

         DumpBIG5();

 

         return 0;

}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值