Forum: Ruby How to decode the following string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4a40ca6c50b8f30d66e02c0c50498f81?d=identicon&s=25 Rich Ard (richard)
on 2006-04-29 09:21
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
357558a6682f4d6624594763d9acdb35?d=identicon&s=25 Mike Fletcher (fletch)
on 2006-04-30 14:25
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.
0ca6e5c33d7e7ff901d75ff0b13d9e1c?d=identicon&s=25 Sam Roberts (Guest)
on 2006-05-03 18:57
(Received via mailing list)
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/...

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
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-03 18:58
(Received via mailing list)
On May 1, 2006, at 8:23 AM, Sam Roberts 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
4a40ca6c50b8f30d66e02c0c50498f81?d=identicon&s=25 Rich Ard (richard)
on 2006-05-16 07:37
Eric Hodel wrote:
> On May 1, 2006, at 8:23 AM, Sam Roberts 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 Hodel - drbrain@segment7.net - http://blog.segment7.net
> This implementation is HODEL-HASH-9600 compliant
>
> http://trackmap.robotcoop.com

thank you all. i will dig those links...
This topic is locked and can not be replied to.