Module: Mail::ParserTools

Defined in:
lib/loose_mail.rb

Instance Method Summary collapse

Instance Method Details

#chars(data, from_bytes, to_bytes) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/loose_mail.rb', line 43

def chars(data, from_bytes, to_bytes)
  s = data.slice(from_bytes..to_bytes)
  if from_bytes != 0 && data[from_bytes - 1] == '"' && data[to_bytes + 1] == '"' # quoted string
    s.gsub!(/\\(.)/) { $1 }
  end
  s.force_encoding(Encoding::UTF_8)
end