[Mime] QuotedPrintableEncoding帮助类 (转载)
点击下载 QuotedPrintableEncoding.rar
这个类是关于QuotedPrintableEncoding的帮助类
看下面代码吧
/// <summary>
/// 类说明:Assistant
/// 编 码 人:苏飞
/// 联系方式:361983679
/// 更新网站:[url=http://www.cckan.net/thread-655-1-1.html]http://www.cckan.net/thread-655-1-1.html[/url]
/// </summary>
using System;
using System.IO;
using System.Text.RegularExpressions; namespace DotNet.Utilities
{
/// <summary>
/// This class is based on the QuotedPrintable class written by Bill Gearhart
/// </summary>
public static class QuotedPrintableEncoding
{
private const string Equal = "="; private const string HexPattern = "(\\=([0-9A-F][0-9A-F]))"; public static string Decode(string contents)
{
if (contents == null)
{
throw new ArgumentNullException("contents");
} using (StringWriter writer = new StringWriter())
{
using (StringReader reader = new StringReader(contents))
{
string line;
while ((line = reader.ReadLine()) != null)
{
/*remove trailing line whitespace that may have
been added by a mail transfer agent per rule
#3 of the Quoted Printable section of RFC 1521.*/
line.TrimEnd(); if (line.EndsWith(Equal))
{
writer.Write(DecodeLine(line));
} //handle soft line breaks for lines that end with an "="
else
{
writer.WriteLine(DecodeLine(line));
}
}
}
writer.Flush(); return writer.ToString();
}
} private static string DecodeLine(string line)
{
if (line == null)
{
throw new ArgumentNullException("line");
} Regex hexRegex = new Regex(HexPattern, RegexOptions.IgnoreCase); return hexRegex.Replace(line, new MatchEvaluator(HexMatchEvaluator));
} private static string HexMatchEvaluator(Match m)
{
int dec = Convert.ToInt32(m.Groups[].Value, );
char character = Convert.ToChar(dec);
return character.ToString();
}
}
}
[Mime] QuotedPrintableEncoding帮助类 (转载)的更多相关文章
- [Mime] MimeHeaders--MimeHeader帮助类 (转载)
点击下载 MimeHeaders.rar 这个类是关于Mime的Headers类看下面代码吧 /// <summary> /// 类说明:Assistant /// 编 码 人:苏飞 // ...
- [Mime] MimeEntity--MimeEntity Mime实体帮助类 (转载)
点击下载 MimeEntity.rar 这个类是关于Mime实体的类看下面代码吧 /// <summary> /// 类说明:Assistant /// 编 码 人:苏飞 /// 联系方式 ...
- [Mime] MimeReader--读取Mime的帮助类 (转载)
点击下载 MimeReader.rar 这个类是关于MimeReader的帮助类看下面代码吧 /// <summary> /// 类说明:Assistant /// 编 码 人:苏飞 // ...
- 常用MIME类型(Flv,Mp4的mime类型设置)(转载)
转载地址:http://www.cuplayer.com/player/Help/2011/0625/83.html 也许你会在纳闷,为什么我上传了flv或MP4文件到服务器,可输入正确地址通过htt ...
- JAVA的StringBuffer类(转载整理)____非常重要的一个类,线程安全,不用每次创建一个对象,以及和String的区别
核心部分转载自:http://www.cnblogs.com/springcsc/archive/2009/12/03/1616330.html StringBuffer类和String一样,也用来代 ...
- GJM :FPSCalc-简单FPS观测类 [转载]
版权声明:本文原创发表于 [请点击连接前往] ,未经作者同意必须保留此段声明!如有侵权请联系我删帖处理! FPSCalc--简单FPS观测类 利用Unity做的手游项目很多时候要保证流畅度,流畅度最直 ...
- 探索Win32系统之窗口类(转载)
Window Classes in Win32 摘要 本文主要介绍win32系统里窗口类的运做和使用机制,探索一些细节问题,使win32窗口类的信息更加明朗化. 在本文中,"类", ...
- [序列化] Serialize--序列化帮助类 (转载)
点击下载 Serialize.zip 这个类是关于加密,解密的操作,文件的一些高级操作1.序列化2.要序列化的类3.序列化例子看下面代码吧 /// <summary> /// 类说明:As ...
- [时间操作] C#TimeHelper时间格式化帮助类 (转载)
点击下载 TimeHelper.rar 主要功能如下 .将时间格式化成 年月日 的形式,如果时间为null,返回当前系统时间 .将时间格式化成 时分秒 的形式,如果时间为null,返回当前系统时间 . ...
随机推荐
- Unreachable catch block for IOException. This exception is never thrown from the try statement body
Unreachable catch block for IOException. This exception is never thrown from the try statement body ...
- POJ_3579_Median_(二分,查找第k大的值)
描述 http://poj.org/problem?id=3579 给你一串数,共C(n,2)个差值(绝对值),求差值从大到小排序的中值,偶数向下取. Median Time Limit: 1000M ...
- Beta Round #9 (酱油杯noi考后欢乐赛)PLQ的寻宝
题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...
- 【转】eclipse android 设置及修改生成apk的签名文件 -- custom debug keystore
原文网址:http://hold-on.iteye.com/blog/2064642 android eclipse 设置及修改生成apk的签名文件 1. 问题: 平时在使用eclipse进行andr ...
- [转]IIS上部署网站
如何在IIS6,7中部署ASP.NET网站 阅读目录 开始 查看web.config文件 在IIS中创建网站 IIS6 添加扩展名映射 IIS6 无扩展名的映射 目录的写入权限 SQL SERVER的 ...
- c# const与readonly 关键字的比较
C#中,const 与readonly是两个比较有用的关键字.const 与 readonly 定义的数据成员在初始化都不能再改变. 比如定义了 public class MathUtitlity ...
- php--常用的时间处理函数
天地四方曰宇,往古来今曰宙 时间是世界的重要组成部分,不论花开花落,还是云卷云舒都有它的影子. 但它源起何处?又将去向何方?没人知道答案,也不需要答案,我们需要的只是一个相对的起点来标识时间,现今世界 ...
- selenium webdriver(4)---模拟鼠标键盘操作
webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...
- [并发编程]使用线程安全队列和条件变量的notify来安排分步骤任务
// 方法1:直接构建N个THread来run foreach (i, size) { thread trd(&Instance::doWork, &inst); lstTrd.pus ...
- JavaScript---网络编程(2)-函数与数组
上节,学完循环了~ 现在学Javascript的函数和数组. JavaScript语法 每一种语言都有自己的语法规则,JS语法与Java很像,所以学习起来比较容易.JS中也一样有变量,语句,函数,数组 ...