Module: BlueFeather::EncodingType

Defined in:
lib/bluefeather.rb

Constant Summary collapse

EUC =
'euc-jp'
EUCJP =
EUC_JP = EUC
SJIS =
'shift-jis'
SHIFT_JIS =
SJIS
UTF8 =
'utf-8'
UTF_8 =
UTF8
ASCII =
'ascii'
US_ASCII =
ASCII

Class Method Summary collapse

Class Method Details

.type_to_charset(type) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/bluefeather.rb', line 126

def self.type_to_charset(type)
  case type
  when EUC
    'euc-jp'
  when SJIS
    'shift_jis'
  when UTF8
    'utf-8'
  when ASCII, nil
    nil
  else
    raise EncodingError, "not adapted encoding type - #{type} (shift-jis, euc-jp, utf-8, or ascii)"
  end
end

.type_to_kcode(type) ⇒ Object



114
115
116
117
118
119
120
121
122
123
# File 'lib/bluefeather.rb', line 114

def self.type_to_kcode(type)
  case type
  when EUC, SJIS, UTF8
    type
  when ASCII
    'none'
  else
    raise EncodingError, "not adapted encoding type - #{type} (shift-jis, euc-jp, utf-8, or ascii)"
  end
end