Skip to content

Instantly share code, notes, and snippets.

@cristibalan
Created December 17, 2009 05:23
Show Gist options
  • Save cristibalan/258544 to your computer and use it in GitHub Desktop.
Save cristibalan/258544 to your computer and use it in GitHub Desktop.
require 'iconv'
require 'rubygems'
require 'mail'
s = Mail::SubjectField.new("From", 'Subject: =?ISO-8859-1?Q?Re=3A_ol=E1?=')
s.decoded # => "Re: ol\341" (LATIN1 bytes)
Iconv.conv("UTF8", "LATIN1", s.decoded) # => "Re: ol\303\241" (UTF8 bytes)
Mail::Encodings.unquote_and_convert_to(s.value, 'UTF8') # => "Re: ol\303\241" (UTF8 bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment