Class: Mail::Encodings::QuotedPrintable
Constant Summary
collapse
- NAME =
'quoted-printable'
- PRIORITY =
2
Class Method Summary
collapse
can_transport?, get_best_compatible, to_s, #to_s
Class Method Details
.can_encode?(str) ⇒ Boolean
11
12
13
|
# File 'lib/mail/encodings/quoted_printable.rb', line 11
def self.can_encode?(str)
EightBit.can_encode? str
end
|
.cost(str) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/mail/encodings/quoted_printable.rb', line 25
def self.cost(str)
c = str.count("\x9\xA\xD\x20-\x3C\x3E-\x7E")
total = (str.bytesize - c)*3 + c
total.to_f/str.bytesize
end
|
.decode(str) ⇒ Object
Decode the string from Quoted-Printable. Cope with hard line breaks that were incorrectly encoded as hex instead of literal CRLF.
17
18
19
|
# File 'lib/mail/encodings/quoted_printable.rb', line 17
def self.decode(str)
str.gsub(/(?:=0D=0A|=0D|=0A)\r\n/, "\r\n").unpack("M*").first.to_lf
end
|
.encode(str) ⇒ Object
21
22
23
|
# File 'lib/mail/encodings/quoted_printable.rb', line 21
def self.encode(str)
[str.to_lf].pack("M").to_crlf
end
|