解码问题 急(gbk\gb18030\utf)

ou630j 2009-02-10 09:50:58
如下
1
=?gbk?B?1965pMT6usOjobnY09q+2bDsIKGwxvPStdDFz6K53A==?= =?gbk?B?wO3KpqGxILn6vNLWsNK118q48cXg0bWw4LXEzajWqg==?=
解码后得到:
2
=?GB18030?B?1Pi659TGLMvEtKjA7bmk0afUui3Cw9POudw=?= =?GB18030?B?
解码后得到:

3
=?GB2312?B?W0JVTEtdIA==?= =?GB2312?B?bWlzILfnyfrLrsbw?=
解码后得到:
[BULK] 风生水起



我想知道上面的解码的函数,不要说用base64解码或者直接在网上找个GetTitle就可以了 解出来都有问题,所以特别发帖问
还有能提供邮件的编码和解码方式都可以给分,分不够就说了。
...全文
655 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanglihnzmd 2011-05-24
  • 打赏
  • 举报
回复
标题乱码问题
crazy_cowboy 2009-02-11
  • 打赏
  • 举报
回复
学习
僵哥 2009-02-10
  • 打赏
  • 举报
回复
也可以这样子写,那么GBK和GB18030就都可以解出来了。
unit Unit7;

interface

//{$i IdCompilerDefines.inc}

uses
IdGlobal, IdHeaderCoderBase;

type
TIdHeaderCoderGB18030 = class(TIdHeaderCoder)
public
class function Decode(const ACharSet, AData: String): String; override;
class function Encode(const ACharSet, AData: String): String; override;
class function CanHandle(const ACharSet: String): Boolean; override;
end;

TIdHeaderCoderGBK = class(TIdHeaderCoder)
public
class function Decode(const ACharSet, AData: String): String; override;
class function Encode(const ACharSet, AData: String): String; override;
class function CanHandle(const ACharSet: String): Boolean; override;
end;
implementation

class function TIdHeaderCoderGB18030.Decode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.Encode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.CanHandle(const ACharSet: String): Boolean;
begin
Result := TextIsSame(ACharSet, 'GB18030');
end;

class function TIdHeaderCoderGBK.Decode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGBK.Encode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGBK.CanHandle(const ACharSet: String): Boolean;
begin
Result := TextIsSame(ACharSet, 'GBK');
end;

initialization
RegisterHeaderCoder(TIdHeaderCoderGB18030);
RegisterHeaderCoder(TIdHeaderCoderGBK);
finalization
UnregisterHeaderCoder(TIdHeaderCoderGB18030);
UnregisterHeaderCoder(TIdHeaderCoderGBK);
end.
僵哥 2009-02-10
  • 打赏
  • 举报
回复
举个例子,把下面这个单元添加到你的程序当中就可以解出GB18030
unit Unit7;

interface

//{$i IdCompilerDefines.inc}

uses
IdGlobal, IdHeaderCoderBase;

type
TIdHeaderCoderGB18030 = class(TIdHeaderCoder)
public
class function Decode(const ACharSet, AData: String): String; override;
class function Encode(const ACharSet, AData: String): String; override;
class function CanHandle(const ACharSet: String): Boolean; override;
end;
implementation

class function TIdHeaderCoderGB18030.Decode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.Encode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.CanHandle(const ACharSet: String): Boolean;
begin
Result := TextIsSame(ACharSet, 'GB18030');
end;

initialization
RegisterHeaderCoder(TIdHeaderCoderGB18030);
finalization
UnregisterHeaderCoder(TIdHeaderCoderGB18030);
end.
僵哥 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ou630j 的回复:]
DecodeHeader函数 这个解不出来的啊?
僵哥你试过的没有啊
[/Quote]
在3楼我不是有回复过了么?

具体的实现可以参考IdHeaderCoderBig5.pas
ou630j 2009-02-10
  • 打赏
  • 举报
回复
DecodeHeader函数 这个解不出来的啊?
僵哥你试过的没有啊
ou630j 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
请参考
http://topic.csdn.net/u/20090204/17/138f7429-0dd3-4a66-be53-e01a28d56a25.html
[/Quote]

这个帖子也是我问的,我早看了,要是解决了我还会问吗?
气人
僵哥 2009-02-10
  • 打赏
  • 举报
回复
需要注意的是,Indy默认包含GB2312,但是并没有包含GBK和GB18030,这个需要调用IdHeaderCoderBase.pas当中RegisterHeaderCoder进行注册。
僵哥 2009-02-10
  • 打赏
  • 举报
回复
IdCoderHeader.pas当中有一个DecodeHeader函数可以帮你解出来。
bdmh 2009-02-10
  • 打赏
  • 举报
回复
请参考
http://topic.csdn.net/u/20090204/17/138f7429-0dd3-4a66-be53-e01a28d56a25.html
僵哥 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 27 楼 ou630j 的回复:]
很多问题的?等于要把控件换了,差点系统崩毁
[/Quote]
先要说清楚你的使用环境,比如是要让现有的控件支持相应的功能还是说只要实现这个功能就可以。如果是只需要实现这个功能,那么就只需要引入Indy10的相关单元(为防止冲突,可以改一下单元的名称),如果是要在现有的控件上实现那么就相对麻烦一点,比如由现有的控件上面继承下来,然后覆盖相应的实现等。
ou630j 2009-02-10
  • 打赏
  • 举报
回复
很多问题的?等于要把控件换了,差点系统崩毁
僵哥 2009-02-10
  • 打赏
  • 举报
回复
用Indy10里面的IdCoderHeader,最好是直接添加到工程当中,或者重命名。
ou630j 2009-02-10
  • 打赏
  • 举报
回复
别那么凶啊?大侠
是我错了,不好意思

unit Unit7;

interface

//{$i IdCompilerDefines.inc}

uses
IdGlobal, IdHeaderCoderBase;

type
TIdHeaderCoderGB18030 = class(TIdHeaderCoder)
public
class function Decode(const ACharSet, AData: String): String; override;
class function Encode(const ACharSet, AData: String): String; override;
class function CanHandle(const ACharSet: String): Boolean; override;
end;

TIdHeaderCoderGBK = class(TIdHeaderCoder)
public
class function Decode(const ACharSet, AData: String): String; override;
class function Encode(const ACharSet, AData: String): String; override;
class function CanHandle(const ACharSet: String): Boolean; override;
end;
implementation

class function TIdHeaderCoderGB18030.Decode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.Encode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGB18030.CanHandle(const ACharSet: String): Boolean;
begin
Result := TextIsSame(ACharSet, 'GB18030');
end;

class function TIdHeaderCoderGBK.Decode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGBK.Encode(const ACharSet, AData: String): String;
begin
Result := AData;

end;

class function TIdHeaderCoderGBK.CanHandle(const ACharSet: String): Boolean;
begin
Result := TextIsSame(ACharSet, 'GBK');
end;

initialization
RegisterHeaderCoder(TIdHeaderCoderGB18030);
RegisterHeaderCoder(TIdHeaderCoderGBK);
finalization
UnregisterHeaderCoder(TIdHeaderCoderGB18030);
UnregisterHeaderCoder(TIdHeaderCoderGBK);
end.
这个加进去也是一样的,
调用那个IdCoderHeader.DecodeHeader还是解码不了的
应该怎么做啊?
僵哥 2009-02-10
  • 打赏
  • 举报
回复
什么叫玩你?当你没事儿干的么?莫明其妙,自己能处理就处理,处理不了拉倒。
僵哥 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 ou630j 的回复:]
老大别玩我了,你贴出来吧
TextIsSame这个在那里找的


ToDo;

这个又什么意思啊?
[/Quote]
TextIsSame,如果我没有记错的话在StrUtils单元当中就有一个SameText.

具体的代码,我上面都已经贴出来了,为什么还要去看那个BIG5的实现框架?
ou630j 2009-02-10
  • 打赏
  • 举报
回复
老大别玩我了,你贴出来吧
TextIsSame这个在那里找的


ToDo;

这个又什么意思啊?
僵哥 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 ou630j 的回复:]
Result := TextIsSame(ACharSet, 'GB18030');


TextIsSame这个是什么函数来的,说找不到
[/Quote]
忽略大小写的一个字符串比较,相等返回true,否则返回false.
ou630j 2009-02-10
  • 打赏
  • 举报
回复
Result := TextIsSame(ACharSet, 'GB18030');


TextIsSame这个是什么函数来的,说找不到
僵哥 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 ou630j 的回复:]
Indy10是一个exe文件,要安装的,安装我原来得控件indy9的就不见了
[/Quote]
http://indy.fulgan.com/ZIP/indy10.zip

或者
http://download.csdn.net/source/583914
加载更多回复(10)

5,390

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧