Class: Dkim::Encodings::DkimQuotedPrintable

Inherits:
Object
  • Object
show all
Defined in:
lib/dkim/encodings/dkim_quoted_printable.rb

Overview

Implements DKIM-Quoted-Printable as described in rfc6376 section 2.11

Constant Summary collapse

DkimUnafeChar =
/[^\x21-\x3A\x3C\x3E-\x7E]/

Instance Method Summary collapse

Instance Method Details

#decode(string) ⇒ Object



12
13
14
15
16
# File 'lib/dkim/encodings/dkim_quoted_printable.rb', line 12

def decode string
  string.gsub(/=([0-9A-F]{2})/) do
    $1.hex.chr
  end
end

#encode(string) ⇒ Object



7
8
9
10
11
# File 'lib/dkim/encodings/dkim_quoted_printable.rb', line 7

def encode string
  string.gsub(DkimUnafeChar) do |char|
    "=%.2x" % char.unpack('C')
  end
end