查看完整版本: Quoted-Printable 简单 C 代码

qqbeiyao 2007-3-11 13:06

Quoted-Printable 简单 C 代码

int quoted_to_str(const char *src, char *target, int targsize)
{
        int srclen;
        int i, j;
        char ch, ch1, ch2;
        unsigned char hz;
        srclen = strlen(src);
        for(i = 0, j = 0; i < srclen || j < targsize ; i++, j++) {
                ch = src[i];
                if (ch == '=') {
                        ch1 = src[++i];
                        ch2 = src[++i];
                        hz = (ch1>'9'?ch1-'A'+10:ch1-'0')*16+
                                (ch2>'9'?ch2-'A'+10:ch2-'0');
                        target[j] = hz;
                } else target[j] = ch;
        }
        return j;
}
代码缺点,没有判断src target 是否为NULL等系列问题。
页: [1]

查看完整版本: Quoted-Printable 简单 C 代码