Module: Piola::Encoding
- Defined in:
- lib/piola/encoding.rb
Instance Method Summary collapse
Instance Method Details
#iso? ⇒ Boolean
23 24 25 26 27 28 29 30 31 |
# File 'lib/piola/encoding.rb', line 23 def iso? begin self.encoding.name == 'ISO-8859-1' rescue ArgumentError => e return false if e. == 'invalid byte sequence in ISO-8859-1' rescue Encoding::CompatibilityError return false end end |
#to_iso ⇒ Object
5 6 7 |
# File 'lib/piola/encoding.rb', line 5 def to_iso self.force_encoding('ISO-8859-1') end |
#to_utf8 ⇒ Object
9 10 11 |
# File 'lib/piola/encoding.rb', line 9 def to_utf8 self.force_encoding('UTF-8') end |
#utf8? ⇒ Boolean
13 14 15 16 17 18 19 20 21 |
# File 'lib/piola/encoding.rb', line 13 def utf8? begin self.encoding.name == 'UTF-8' rescue ArgumentError => e return false if e. == 'invalid byte sequence in UTF-8' rescue Encoding::CompatibilityError return false end end |