Email中Quoted Printable的解码方法

代码
public static string QPDecode(string content,string encodingOption)
        {
            content 
= content.Replace("=\r\n"""); 

             
char[] chars = content.ToCharArray(); 
 
             
byte[] bytes = new byte[chars.Length]; 
 
             
int bytesCount = 0
 
             
for (int i = 0; i < chars.Length; i++
             { 
 
                 
if (chars[i] == '='
                 { 
                     bytes[bytesCount
++= System.Convert.ToByte(int.Parse(chars[i + 1].ToString() + chars[i + 2].ToString(), System.Globalization.NumberStyles.HexNumber)); 
 
                     i 
+= 2
                 } 
                 
else 
                 { 
                     bytes[bytesCount
++= System.Convert.ToByte(chars[i]); 
                 } 
             } 
 
 
             
return System.Text.Encoding.GetEncoding(encodingOption).GetString(bytes, 0, bytesCount);
        }


posted on 2010-04-30 10:43  MoonWalker  阅读(183)  评论(0编辑  收藏  举报

导航