建立小型汉字库的方法

Author: 袁津生 Date: 1993-07-30

        建立汉字库程序是用Turbo C编写的。
        源程序如下:
        /建立汉字库程序/
        #include"stdlib.h"
        #include"stdio.h"
        #include"fcntl.h"
        #include"graphics.h"
        char  buffer[32];
        FILEfp,fpl;
        intxl,x2,i,f=0;
        unsigned  charhz,str[40];longhs;
        main()
        {
        intdriver=VGA,mode=2;
        initgraph(&driver,&mode,"");
        fp=fopen("c:\\213
        \\hzk16","rb");
        /*打开字库文件/
        if(fp==NULL){print  f("could  not  open  hzk16!");exit(1);}
        while(1){
        fpl=fopen("xhzk","ab");
        /打开小型汉字库/
        printf("\n请输入汉字[Q]退出!");
        hz=str;
        scanf("%s",hz);
        if(str[0]=='Q')break;
        while((i=hz++)!=0){
        if(i〉0xal)
        if(f==0){
        xl=(i0xal)&0x07f;
        f=1;}
        else{
        x2=(i0xal)&0x07f;
        f=0;
        hs=(xl_23)94321+(x223)321;
        /字模在字库中地址/fseek(fp,hs,SEEK___SET);/确定指针位置/
        fread(buffer,32,1,fp);
        /将数据读入内存/
        fwrite(buffer,32,1,fpl);
        /写数据到新字库/
        }}
        fclose(fpl);}
        fclose(fp);
        }