Bug 5028 - Add Quoted-Printable encode/decode methods to TMail::Mail class
Summary: Add Quoted-Printable encode/decode methods to TMail::Mail class
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: ruby-tmail (show other bugs)
Version: unstable
Hardware: all Linux
: P2 enhancement
Assignee: nbr
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-20 09:11 MSD by Sir Raorn
Modified: 2008-04-12 23:26 MSD (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sir Raorn 2004-08-20 09:11:08 MSD
Something like that:

module TMail
    class Mail
	def qp_encode
	    store 'Content-Transfer-Encoding', 'Quoted-Printable'
	    self.body = [self.body].pack('M')
	    end
	end
	def qp_decode
	    if /quoted-printable/i =~ self.transfer_encoding('')
		store 'Content-Transfer-Encoding', '8bit'
		self.body = self.body.unpack('M')
	    end
	end
    end
end
Comment 1 Michael Shigorin 2005-11-04 10:44:24 MSK
LOL.  Вчера ровно этим (decode only, QP+B64) и занимался:

require 'tmail/mail'

module TMail
  class Mail
    def decode
      case transfer_encoding
      when nil then return body
      when "base64" then return body.unpack('m*')
      when "quoted-printable" then return body.unpack('M*')
      else return body #raise "Unknown encoding: #{transfer_encoding}"
      end
    end 
    #def save(file=nil, decode=true)
    # # filename can be set or taken from the mail itself
    # file = disposition_param('filename') unless file
    #end
  end
end
Comment 2 Sir Raorn 2008-04-12 23:26:16 MSD
Ну в общем новый TMail умеет и QP тоже.