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
- .convert_to_charset(str_value) ⇒ Object
- .convert_to_kcode(str_value) ⇒ Object
- .regulate(str_value) ⇒ Object
Class Method Details
.convert_to_charset(str_value) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/bluefeather.rb', line 145 def self.convert_to_charset(str_value) type = self.regulate(str_value) case type when EUC 'euc-jp' when SJIS 'shift_jis' when UTF8 'utf-8' when ASCII nil end end |
.convert_to_kcode(str_value) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'lib/bluefeather.rb', line 134 def self.convert_to_kcode(str_value) type = self.regulate(str_value) case type when EUC, SJIS, UTF8 type when ASCII 'none' end end |
.regulate(str_value) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/bluefeather.rb', line 119 def self.regulate(str_value) case str_value.downcase when 'shift-jis', 'shift_jis' SJIS when 'euc-jp' EUC when 'utf-8' UTF8 when 'ascii' ASCII else raise EncodingError, "not adapted encoding type - #{str_value} (shift[-_]jis, euc-jp, utf-8, or ascii)" end end |