社区
C#
帖子详情
请各位发个邮件中quoted printable的编码函数,c#的,不要解码,只要编码的~
liuguozhong
2007-03-20 08:49:52
如题,谢谢了~
...全文
273
9
打赏
收藏
请各位发个邮件中quoted printable的编码函数,c#的,不要解码,只要编码的~
如题,谢谢了~
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
王集鹄
2007-03-20
打赏
举报
回复
//硬写一个也不难...
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 路过"));
}
liuguozhong
2007-03-20
打赏
举报
回复
zswang(伴水清清)(专家门诊清洁工) :
先谢过,可是我要字符串转化为qp编码呢~
王集鹄
2007-03-20
打赏
举报
回复
附件里可以指定编码方式,参考:
Attachment vAttachment = new Attachment("yourfile");
vAttachment.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
liuguozhong
2007-03-20
打赏
举报
回复
50分没人要啊~
richard530
2007-03-20
打赏
举报
回复
up~
liuguozhong
2007-03-20
打赏
举报
回复
再顶一下,怎么没有人帮忙呀~
liuguozhong
2007-03-20
打赏
举报
回复
人工置顶~
liuguozhong
2007-03-20
打赏
举报
回复
顶一下,谢谢了~
liuguozhong
2007-03-20
打赏
举报
回复
感谢~
共享
quote
d-
pr
int
able
解码
(
C#
)-转载
本文介绍了一种使用
C#
实现的
quote
d-
pr
int
able
邮件
解码
方法,并提供了具体的代码示例。作者在实现
邮件
收发的过程
中
遇到了
解码
问题,特别是针对
quote
d-
pr
int
able
编码
方式。文
中
详细解释了解决方案,包括如何将特定格式的字符串转换为字符。
C#
中
Quote
d
Pr
int
able
编
解码
本文介绍了一种基于
C#
的
Quote
d-
Pr
int
able
(QP)
编码
及
解码
的方法。通过两个公共
函数
实现了文本到QP
编码
的转换以及QP
编码
回转为原始文本的过程。此
编码
方式主要用于电子
邮件
等场景
中
,确保非ASCII字符能够被正确传输。
乱码算法大全
本文详细阐述互联网常用
编码
的
编码
和
解码
算法,包括Uuencode、Xxencode、Base64、
Quote
d -
Pr
int
able
等,给出C语言实现代码。还介绍汉字
编码
如GB码、Big5码、HZ码,以及其他
编码
如Unicode、Binhex,相关文档和源码可在作者主页下载。
C#
111,131
社区成员
642,542
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章