PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/fontextract/gb2312.c

http://ftk.googlecode.com/
C | 67 lines | 50 code | 16 blank | 1 comment | 7 complexity | 5a228a29a9ebfa3d94382aa3fc9ba99d MD5 | raw file
 1//Build gcc -g gb.c -o gb.exe
 2
 3#include <stdio.h>
 4
 5static void DumpAscii(FILE* fp)
 6{
 7	unsigned char c = 0;
 8	for(c = 32; c < 128; c++)
 9	{
10      fwrite (&c, sizeof (c), 1, fp);
11	}
12
13	return;
14}
15
16static void DumpRange (FILE * fp, unsigned short n)
17{
18  unsigned char c = 0;
19  unsigned short i = 0;
20
21  for (i = 0; i < (0xFF - 0xA0); i++)
22    {
23      c = 0xA0 + n;
24      fwrite (&c, sizeof (c), 1, fp);
25      c = 0xA0 + i;
26      fwrite (&c, sizeof (c), 1, fp);
27    }
28
29  fflush (fp);
30
31  return;
32}
33
34static void DumpGB2312 (void)
35{
36  unsigned short i = 0;
37
38  FILE *fp = fopen ("gb.txt", "wb+");
39
40  if (fp != NULL)
41    {
42		DumpAscii(fp);
43      for (i = 1; i <= 9; i++)
44		DumpRange (fp, i);
45
46      for (i = 16; i <= 55; i++)
47		DumpRange (fp, i);
48
49      for (i = 56; i <= 87; i++)
50		DumpRange (fp, i);
51
52      fclose (fp);
53    }
54  else
55    {
56      perror ("fopen");
57    }
58
59  return;
60}
61
62int main (int argc, char *argv[])
63{
64  DumpGB2312 ();
65
66  return 0;
67}