On 04/18/2005 11:46 PM, Adriano Ferreira wrote: > On 4/18/05, Dr Balwinder S Dheeman <bsd.SANSPAM / cto.homelinux.net> wrote: > >>Ho do I decode MIME encoded strings like >>"=?ISO-8859-15?Q?Jes=FAs_=C1ngel?=", to 8 and, or 7 bit ASCII? > > > The "Q" means it uses the encoding known as "quoted-printable". This > and Base64 are the usual encodings in MIME. QuotedPrintable is simpler > and results in longish encoded strings, being suitable for texts with > a few characters out of ASCII 7-bit range. > > From "[SUMMARY] Quoted Printable (#23)" > (http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/133976) sent to > this mailing list, > > class String > def to_quoted_printable(*args) > [self].pack("M").gsub(/\n/, "\r\n") > end > def from_quoted_printable > self.gsub(/\r\n/, "\n").unpack("M").first > end > end > > provides the solution you want. Just try: > > s = "Jes=FAs_=C1ngel"; > print s.from_quoted_printable > Thanks a lot, after testing adding: def decode_q(str) str.gsub!(/=\?ISO-8859-[1-9]*\?Q\?([!->@-~]+)\?=/i) { $1.unpack("M").first } str.gsub!(/_/, " ") str end to my program/script. -- Dr Balwinder Singh Dheeman Registered Linux User: #229709 CLLO (Chief Linux Learning Officer) Machines: #168573, 170593, 259192 Anu's Linux@HOME Distros: Ubuntu, Fedora, Knoppix More: http://anu.homelinux.net/~bsd/ Visit: http://counter.li.org/