Sha256: 271a603e54ca9feaf400f36d270f09750647eaa2a33af2f445a16a6b8a58ba16
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
module ROXML module CoreExtensions #:nodoc: module String # Extension of String class to handle conversion from/to # UTF-8/ISO-8869-1 module Conversions require 'iconv' # # Return an utf-8 representation of this string. # 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 # # Convert this string to iso-8850-1 # 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 end end end end class Object end class String def between(separator, &block) split(separator).collect(&block).join(separator) end end
Version data entries
12 entries across 12 versions & 2 rubygems