How to decode the following string


#1

hello,

when i work on a pop mail client program, i met the following string at
the Subject field:

Subject: =?GBK?B?dnNvYy5jbiDXorLhs8m5piE==?=
Subject: =?GB2312?B?RndkOiCyu7rD0uLLvKOsvfHM7LLF1qq1wMTjtcTTys/k?=

i know they are encoded chinese words. but anybody can advise on how to
decode them?

regards and thanks,

Richard


#2

Rich Ard wrote:

hello,

when i work on a pop mail client program, i met the following string at
the Subject field:

Subject: =?GBK?B?dnNvYy5jbiDXorLhs8m5piE==?=
Subject: =?GB2312?B?RndkOiCyu7rD0uLLvKOsvfHM7LLF1qq1wMTjtcTTys/k?=

i know they are encoded chinese words. but anybody can advise on how to
decode them?

Doing some quick googling shows that the quoted-printable format for
headers is

=?Charset?encoding?encoded text?=

So these are in the GBK and GB2312 charsets respectively, both encoded
in Base64. You could use a regexp to pull the three fields out and then
use the standard Base64.decode64 to recover the encoded characters from
the last chunk.


#3

On May 1, 2006, at 8:23 AM, Sam R. wrote:

i know they are encoded chinese words. but anybody can advise on
Something like it really, REALLY should be part of one of the ruby
mail libraries… even Net::IMAP if necessary.

I believe TMail supports this.


Eric H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com


#4

Rich Ard wrote:

hello,

when i work on a pop mail client program, i met the following string at
the Subject field:

Subject: =?GBK?B?dnNvYy5jbiDXorLhs8m5piE==?=
Subject: =?GB2312?B?RndkOiCyu7rD0uLLvKOsvfHM7LLF1qq1wMTjtcTTys/k?=

i know they are encoded chinese words. but anybody can advise on how to
decode them?

They are RFC 2047 encoded words. I wrote a small lib to decode them,
this might be the latest version:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/101949

Email me off line if not, and I’ll send it to you.

Something like it really, REALLY should be part of one of the ruby
mail libraries… even Net::IMAP if necessary.

Cheers,
Sam


#5

Eric H. wrote:

On May 1, 2006, at 8:23 AM, Sam R. wrote:

i know they are encoded chinese words. but anybody can advise on
Something like it really, REALLY should be part of one of the ruby
mail libraries… even Net::IMAP if necessary.

I believe TMail supports this.


Eric H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

thank you all. i will dig those links…