RFC 1522指明了一个在RFC 822 报文首部中如何发送非ASCII字符的方法。
这样做的主要用途是为了允许在发送方名、接收方名以及主题中使用其他的字符。
首部字段中可以包含编码字(coded word)。它们具有以下格式:
=?charset?encoding?encoded-text?=charset是字符集规范。比如简体中文是gb2312encoding是一个单个字符用来指定编码方法,支持两个值:B和Q。
B是指Base64编码
Q是指QP(Quote-Printable)编码encoded-text是报文正文,编码格式由encoding指定。解码和编码自己找吧,如果找不到再说一声。
这样做的主要用途是为了允许在发送方名、接收方名以及主题中使用其他的字符。
首部字段中可以包含编码字(coded word)。它们具有以下格式:
=?charset?encoding?encoded-text?=charset是字符集规范。比如简体中文是gb2312encoding是一个单个字符用来指定编码方法,支持两个值:B和Q。
B是指Base64编码
Q是指QP(Quote-Printable)编码encoded-text是报文正文,编码格式由encoding指定。解码和编码自己找吧,如果找不到再说一声。
解决方案 »
- fastReport问题
- 我现在要做个窗体设计器,就是类似Delphi设计窗体一样.要在程序运行时能用鼠标移动控件的位置,改变控件的大小,现在我已经能够移动单个控件,现在想象Delphi一样能够一次选择多个控件并同时移动位置
- delphi 中TString类型的属性中关于strings【index】如何动态赋值?
- 请推荐一本Delphi的学习书籍!
- 求救,数据库的问题
- 简单问题,请帮手,在线等……
- 特难:我在三层中上传ClientDataSet.data属性都能成功。为何下载就不成功了。
- 如何取子串-----------------急急急----在线等
- oracle数据库的查询操作
- delphi5不支持access2000?用.db又不方便
- 窗体位置的移动
- 求助....怎样实现Delphi后台驱动Auto CAD..在线等待!
比如我把主题存为了
Subject.Caption := Msg.Subject;
如何对Subject.Caption 进行解码
var
Coder: TIdBase64Decoder;
Res: string;
begin
Result := '';
Coder := TIdBase64Decoder.Create(nil);
try
Coder.AddCRLF := False;
Coder.UseEvent := False;
Coder.Reset;
Coder.CodeString(s);
Res := Coder.CompletedInput;
Result := Copy(Res, 3, Length(Res));
finally
FreeAndNil(Coder);
end;
end;function DecodeSubject(S: string): string;
var
I : Integer;
Res: string;
begin
I := Length(S);
Dec(I, 2);
while (S[I] <> '?') and (I > 5) do
Dec(I);
Res := Copy(S, I+1, Length(S)-2-I); ShowMessage(Res);
Result := DecodeBase64(Res);
end;Suject.Caption := DecodeSubject(Msg.Subject);如果你的indy升级为最新的版本,可能出错
未经测试
function mybase64(s:string):string;
begin
if copy(s,0,2)<>'=?' then
begin
result:=s;
exit;
end;
s:=copy(s,12,length(s)-12);
s:=copy(s,0,length(s)-2);
frmmain.IdBase64Decoder1.CodeString(s);
s:=frmmain.IdBase64Decoder1.CompletedInput;
result:= Copy(s, 3, Length(s));end; Suject.Caption := mybase64(msg.Subject);
虽然我的语法不是很规范,还能用
呵呵
var
p1,p2:integer;
Temp:string;
begin
result:=s;
while pos('=?',s)<>0 do
begin
p1:=pos('=?',s);
p2:=pos('?=',s);
temp:=Copy(s,p1+11,p2-p1-12);
frmmain.IdBase64Decoder1.CodeString(temp);
temp:=frmmain.IdBase64Decoder1.CompletedInput;
s:=copy(s,1,p1-1)+copy(temp,3,length(temp)-2)+copy(s,p2+2,length(s)-p2+2);
result:=s;
end
end;