Sha256: 02d5b31cd74f875c53837450fc5266805d4adb80c20c1298896632e4c64766b8

Contents?: true

Size: 841 Bytes

Versions: 208

Compression:

Stored size: 841 Bytes

Contents

# encoding: utf-8
require 'mail/encodings/7bit'

module Mail
  module Encodings
    class QuotedPrintable < SevenBit
      NAME='quoted-printable'
   
      PRIORITY = 2

      def self.can_encode?(str)
        EightBit.can_encode? str
      end

      # Decode the string from Quoted-Printable
      def self.decode(str)
        str.unpack("M*").first
      end

      def self.encode(str)
        [str].pack("M").gsub(/\n/, "\r\n")
      end

      def self.cost(str)
        # These bytes probably do not need encoding
        c = str.count("\x9\xA\xD\x20-\x3C\x3E-\x7E")
        # Everything else turns into =XX where XX is a 
        # two digit hex number (taking 3 bytes)
        total = (str.bytesize - c)*3 + c
        total.to_f/str.bytesize
      end
        
      private

      Encodings.register(NAME, self)
    end
  end
end

Version data entries

208 entries across 167 versions & 15 rubygems

Version Path
depengine-0.0.24 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.23 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.22 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.21 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.21 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.20 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.19 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.18 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.17 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/encodings/quoted_printable.rb