Created
August 4, 2010 10:59
-
-
Save gudleik/507969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby -v | |
ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0] | |
# gem list mail | |
mail (2.2.5) | |
irb> require 'mail' | |
irb> source =<<EOT | |
Received: by 10.220.95.198 with SMTP id e6cs20153vcn; | |
Tue, 3 Aug 2010 13:56:07 -0700 (PDT) | |
From: Foobar <[email protected]> | |
To: Test <[email protected]> | |
Content-Class: urn:content-classes:message | |
Date: Tue, 3 Aug 2010 22:56:04 +0200 | |
Subject: Test | |
Message-ID: <A1EFE6B6EFCD5D46AE11D0D2735A537120420A2DCE@localhost> | |
Accept-Language: en-US | |
Content-Language: en-US | |
X-MS-Has-Attach: | |
X-MS-TNEF-Correlator: | |
acceptlanguage: en-US | |
Content-Type: text/plain; charset="windows-1252" | |
Content-Transfer-Encoding: quoted-printable | |
MIME-Version: 1.0 | |
Testing encoded text, like m=E5 and =F8delegge, v=E6re | |
/Foobar, Ingeni=F8r | |
EOT | |
irb> mail = Mail.new source | |
irb> mail.content_transfer_encoding | |
=> "quoted-printable" | |
irb> mail.charset | |
=> "windows-1252" | |
irb> mail.body.encoding | |
=> "quoted-printable" | |
irb> mail.body.charset | |
=> "US-ASCII" | |
irb> mail.body.to_s.encoding | |
=> #<Encoding:US-ASCII> | |
irb> mail.body.to_s | |
=> "Testing encoded text, like m\xE5 and \xF8delegge, v\xE6re\r\n\r\n/Foobar, Ingeni\xF8r" | |
irb> mail.body.to_s == mail.body.decoded | |
=> true | |
irb> mail.body.charset = mail.charset | |
=> "windows-1252" | |
irb> mail.body.to_s.encoding | |
=> #<Encoding:US-ASCII> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment