Module: Gonzui::UTF8
- Defined in:
- lib/gonzui/util.rb
Constant Summary collapse
- Preference =
["iso-2022-jp", "euc-jp", "utf-8", "shift_jis", "cp932", "iso-8859-1", "ascii"]
Class Method Summary collapse
Class Method Details
.set_preference(preference) ⇒ Object
378 379 380 |
# File 'lib/gonzui/util.rb', line 378 def set_preference(preference) Preference.replace(preference) end |
.to_utf8(str) ⇒ Object
382 383 384 385 386 387 388 389 390 391 |
# File 'lib/gonzui/util.rb', line 382 def to_utf8(str) return str, "us-ascii" if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) Preference.each {|name| begin return Iconv.conv("UTF-8", name, str), name rescue Iconv::IllegalSequence, ArgumentError end } return str, "binary" end |