您的位置:程序门 -> .net技术 -> c#



请各位发个邮件中quoted printable的编码函数,c#的,不要解码,只要编码的~


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请各位发个邮件中quoted printable的编码函数,c#的,不要解码,只要编码的~[已结贴,结贴人:liuguozhong]
发表于:2007-03-20 08:49:52 楼主
如题,谢谢了~
发表于:2007-03-20 08:52:561楼 得分:0
顶一下,谢谢了~
发表于:2007-03-20 09:24:102楼 得分:0
人工置顶~
发表于:2007-03-20 09:41:203楼 得分:0
再顶一下,怎么没有人帮忙呀~
发表于:2007-03-20 10:45:164楼 得分:0
up~
发表于:2007-03-20 11:17:015楼 得分:0
50分没人要啊~
发表于:2007-03-20 11:29:396楼 得分:0
附件里可以指定编码方式,参考:

attachment   vattachment   =   new   attachment( "yourfile ");
vattachment.transferencoding   =   system.net.mime.transferencoding.quotedprintable;
发表于:2007-03-20 11:40:337楼 得分:0
zswang(伴水清清)(专家门诊清洁工)   :

先谢过,可是我要字符串转化为qp编码呢~
发表于:2007-03-20 12:01:388楼 得分:50
//硬写一个也不难...  
using   system.collections;
using   system.globalization;

public   string   quotedprintableencode(string   atext)   //   qp编码
{
        string   result   =   " ";
        byte[]   vbuffer   =   encoding.default.getbytes(atext);
        foreach(byte   vbyte   in   vbuffer)
                //   可见字符并非 "= "(#61)
                if   ((vbyte   > =   33   &&   vbyte   <=   60)   ¦ ¦   (vbyte   > =   62   &&   vbyte   <=   126))    
                        result   +=   (char)vbyte;
                else   result   +=   "= "   +   vbyte.tostring( "x2 ");
        return   result;
}

public   static   string   quotedprintabledecode(string   acode)   //   解码
{
        arraylist   vbuffer   =   new   arraylist();
       
        for(int   i   =   0;   i   <   acode.length;   i++)
        {
                if   (acode[i]   ==   '= ')
                {
                        i++;
                        if   (acode[i]   !=   '\r ')
                        {
                                byte   vbyte;
                                if   (byte.tryparse(acode.substring(i,   2),    
                                        numberstyles.hexnumber,   null,   out   vbyte))
                                        vbuffer.add(vbyte);
                        }
                        i++;
                }
                else   if   (acode[i]   !=   '\n ')   vbuffer.add((byte)acode[i]);
        }
        return   encoding.default.getstring((byte[])vbuffer.toarray(typeof(byte)));
}

private   void   button1_click(object   sender,   eventargs   e)
{
        text   =   quotedprintabledecode(quotedprintableencode( "zswang   路过 "));
}
发表于:2007-03-20 13:34:549楼 得分:0
感谢~


快速检索

最新资讯
热门点击