一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

C# Quoted-Printable編碼、解碼

復(fù)制代碼 代碼如下:
# using System;
# using System.Collections;
# using System.Text;
#
# /// <summary>
# /// Class for encoding and decoding a string to QuotedPrintable
# /// RFC 1521 http://www.ietf.org/rfc/rfc1521.txt
# /// RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
# /// Date: 2006-03-23
# /// Author: Kevin Spaun
# /// Company: SPAUN Informationstechnik GmbH - http://www.spaun-it.com/
# /// Feedback: kspaun@spaun-it.de
# /// License: This piece of code comes with no guaranties. You can use it for whatever you want for free.
# ///
# /// Modified by Will Huang ( http://blog.miniASP.com/post/2008/02/14/Quoted-Printable-Encoding-and-Decoding.ASPx )
# /// Modified at 2008-02-13
# ///
# /// Modified by reterry (http://www.jb51.NET)
# /// Modified at 2008-11-29
# /// Modified for MySelf
# ///
# /// </summary>
# public class QuotedPrintable
# {
# private const byte EQUALS = 61;
# private const byte CR = 13;
# private const byte LF = 10;
# private const byte SPACE = 32;
# private const byte TAB = 9;
#
# /// <summary>
# /// Encodes a string to QuotedPrintable
# /// </summary>
# /// <param name="_ToEncode">String to encode</param>
# /// <returns>QuotedPrintable encoded string</returns>
# public static string Encode(string _ToEncode)
# {
# StringBuilder Encoded = new StringBuilder();
# string hex = string.Empty;
# //byte[] bytes = Encoding.Default.GetBytes(_ToEncode);
# byte[] bytes = Encoding.UTF8.GetBytes(_ToEncode);
# //int count = 0;
#
# for (int i = 0; i < bytes.Length; i++)
# {
# //these characters must be encoded
# if ((bytes[i] < 33 || bytes[i] > 126 || bytes[i] == EQUALS) && bytes[i] != CR && bytes[i] != LF && bytes[i] != SPACE)
# {
# if (bytes[i].ToString("X").Length < 2)
# {
# hex = "0" + bytes[i].ToString("X");
# Encoded.Append("=" + hex);
# }
# else
# {
# hex = bytes[i].ToString("X");
# Encoded.Append("=" + hex);
# }
# }
# else
# {
# //check if index out of range
# if ((i + 1) < bytes.Length)
# {
# //if TAB is at the end of the line - encode it!
# if ((bytes[i] == TAB && bytes[i + 1] == LF) || (bytes[i] == TAB && bytes[i + 1] == CR))
# {
# Encoded.Append("=0" + bytes[i].ToString("X"));
# }
# //if SPACE is at the end of the line - encode it!
# else if ((bytes[i] == SPACE && bytes[i + 1] == LF) || (bytes[i] == SPACE && bytes[i + 1] == CR))
# {
# Encoded.Append("=" + bytes[i].ToString("X"));
# }
# else
# {
# Encoded.Append(System.Convert.ToChar(bytes[i]));
# }
# }
# else
# {
# Encoded.Append(System.Convert.ToChar(bytes[i]));
# }
# }
# //if (count == 75)
# //{
# // Encoded.Append("=/r/n"); //insert soft-linebreak
# // count = 0;
# //}
# //count++;
# }
#
# return Encoded.ToString();
# }
#
# /// <summary>
# /// Decodes a QuotedPrintable encoded string
# /// </summary>
# /// <param name="_ToDecode">The encoded string to decode</param>
# /// <returns>Decoded string</returns>
# public static string Decode(string _ToDecode)
# {
# //remove soft-linebreaks first
# //_ToDecode = _ToDecode.Replace("=/r/n", "");
#
# char[] chars = _ToDecode.ToCharArray();
#
# byte[] bytes = new byte[chars.Length];
#
# int bytesCount = 0;
#
# for (int i = 0; i < chars.Length; i++)
# {
# // if encoded character found decode it
# 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.Default.GetString(bytes, 0, bytesCount);
# return System.Text.Encoding.UTF8.GetString(bytes, 0, bytesCount);
# }
# }

AspNet技術(shù)C# Quoted-Printable編碼、解碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 都市激情中文字幕 | 九九这里只有精品视频 | 99色亚洲| 香蕉97超级碰碰碰碰碰久 | 久久综合久久网 | 在线视频一区二区三区 | 久久精品国产精品青草不卡 | 99精品久久秒播无毒不卡 | 国产女人在线 | 色噜噜狠狠在爱丁香 | 日韩一区二三区无 | 日日狠狠久久偷偷四色综合免费 | 在线视频一区二区 | 狠狠干成人 | 日韩综合第一页 | 色视频在线免费看 | 91短视频在线观看免费最新91 | 久久婷婷午色综合夜啪 | 91区国产福利在线观看午夜 | 国产精品第一 | 国产www在线观看 | 一区二区三区中文字幕 | 国产欧美日韩综合精品一区二区三区 | 国内精品自在自线2020 | 国产精品第2页 | 一木道一二三区精品 | 一区二区三区四 | 精品一区二区三区在线视频 | 色人久久 | 久久久久国产视频 | 日本乱人伦在线观看免费 | 曰本视频网络www色 曰韩美女一级视频 | 四虎影视国产在线观看精品 | 久久99精品国产99久久 | 2021久久精品免费观看 | 欧洲成人在线观看 | 亚洲伊人久久大香线蕉苏妲己 | 91精品日本久久久久久牛牛 | 欧美123 | 久久大香萑太香蕉综合网 | 91青青草视频在线观看 |