Class: MailParser::ConvCharset

Inherits:
Object
  • Object
show all
Defined in:
lib/mailparser/conv_charset.rb

Constant Summary collapse

CHARSET =
{
  "sjis"        => "cp932",
  "x-sjis"      => "cp932",
  "shift_jis"   => "cp932",
  "shift-jis"   => "cp932",
}

Class Method Summary collapse

Class Method Details

.conv_charset(from, to, str) ⇒ Object



18
19
20
21
22
# File 'lib/mailparser/conv_charset.rb', line 18

def self.conv_charset(from, to, str)
  from = CHARSET[from.downcase] || from.downcase
  to = CHARSET[to.downcase] || to.downcase
  str.encode(to, from, :invalid=>:replace, :undef=>:replace, :replace=>'?')
end