Parent

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). 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 38
38:       def self.conv(to, from, str)
39:         raise InvalidCharacter, "the 3rd argument is nil" unless str
40:         begin
41:           str = java.lang.String.new(str.unpack("C*").to_java(:byte), from)
42:           str.getBytes(to).to_ary.pack("C*")
43:         rescue java.io.UnsupportedEncodingException
44:           raise InvalidEncoding
45:         end
46:       end
conv(to, from, str) click to toggle source

This is a function equivalent of Iconv.iconv.

  • to: encoding name for destination

  • from: encoding name for source

  • str: strings to be converted

  • Returns: Returns an Array of converted strings.

    # File lib/gettext/core_ext/iconv.rb, line 66
66:           def self.conv(to, from, str)
67:             begin
68:               GLib.convert(str, to, from)
69:             rescue GLib::ConvertError => e
70:               case e.code
71:               when GLib::ConvertError::NO_CONVERSION
72:                 raise InvalidEncoding.new(str)
73:               when GLib::ConvertError::ILLEGAL_SEQUENCE
74:                 raise IllegalSequence.new(str)
75:               else
76:                 raise InvalidCharacter.new(str)
77:               end
78:             end
79:           end
iconv(to, from, str) click to toggle source
    # File lib/gettext/core_ext/iconv.rb, line 96
96:     def self.iconv(to, from, str)
97:       conv(to, from, str).split(//)
98:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.