如何用C程序实现将GB2312的6763个汉字按输出到一个文本文件

引文:http://bbs.chinaunix.net/thread-1293425-1-4.html

某人的写法,GBK方式,两个字节一个汉字:


    int i = 32768;
    for (; i < 65536; i ++)
    {
        if (i % 256 < 0x20)
            printf("  ");
        else
        {
            printf("%c%c", i / 256, i % 256);
            if (i % 32 == 31) printf("\n");
        }
    }


汉字的范围肯定小于等于65535,我们可以将所有从0x20(空格)之后到65535的字符直接循环全部打印出来,这里做了一次UTF8转换:

char.tar.bz2

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on October 21, 2008 2:48 PM.

利用unordered_map代替hash_map was the previous entry in this blog.

程序员经常犯的一个错误:数组越界 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.