//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++)

         {

                   cHigh =  i >> 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;

}