class Iconv

Pseudo Iconv class

For Matz Ruby:

If you don’t have iconv but Ruby/GLib2, this library uses Ruby/GLib2’s iconv functions.

Ruby/GLib is a module which is provided from Ruby-GNOME2 Project. You can get binaries for Win32(One-Click Ruby Installer). <URL: ruby-gnome2.sourceforge.jp/>

For JRuby:

Use Java String class to convert strings.

Public Class Methods

conv(to, from, str) click to toggle source
# File lib/gettext/core_ext/iconv.rb, line 37
def self.conv(to, from, str)
  raise InvalidCharacter, "the 3rd argument is nil" unless str
  begin
    str = java.lang.String.new(str.unpack("C*").to_java(:byte), from)
    str.getBytes(to).to_ary.pack("C*")
  rescue java.io.UnsupportedEncodingException
    raise InvalidEncoding
  end
end
iconv(to, from, str) click to toggle source
# File lib/gettext/core_ext/iconv.rb, line 95
def self.iconv(to, from, str)
  conv(to, from, str).split(%r/)
end