Module: ROXML::CoreExtensions::String::Conversions
- Included in:
- String
- Defined in:
- lib/roxml/extensions/string/conversions.rb
Overview
Extension of String class to handle conversion from/to UTF-8/ISO-8869-1
Instance Method Summary collapse
-
#to_latin ⇒ Object
Convert this string to iso-8850-1.
-
#to_utf ⇒ Object
Return an utf-8 representation of this string.
Instance Method Details
#to_latin ⇒ Object
Convert this string to iso-8850-1
24 25 26 27 28 29 30 31 |
# File 'lib/roxml/extensions/string/conversions.rb', line 24 def to_latin begin Iconv.new("iso-8859-1", "utf-8").iconv(to_s) rescue Iconv::IllegalSequence STDERR << "!! Failed converting from ISO-8859-1 -> UTF-8 (#{self}). Already the right charset?" self end end |
#to_utf ⇒ Object
Return an utf-8 representation of this string.
12 13 14 15 16 17 18 19 |
# File 'lib/roxml/extensions/string/conversions.rb', line 12 def to_utf begin Iconv.new("utf-8", "iso-8859-1").iconv(to_s) rescue Iconv::IllegalSequence STDERR << "!! Failed converting from UTF-8 -> ISO-8859-1 (#{self}). Already the right charset?" self end end |