| Class | Encoding |
| In: |
transcode.c
encoding.c |
| Parent: | Object |
call-seq:
Encoding.aliases => {"alias1" => "orig1", "alias2" => "orig2", ...}
Returns the hash of available encoding alias and original encoding name.
Encoding.aliases
=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1986"=>"US-ASCII",
"SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
Returns the hash of available encoding alias and original encoding name.
Encoding.aliases
=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1986"=>"US-ASCII",
"SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
Checks the compatibility of two strings. If they are compatible, means concatenatable, returns an encoding which the concatinated string will be. If they are not compatible, nil is returned.
Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b")
=> #<Encoding:ISO-8859-1>
Encoding.compatible?(
"\xa1".force_encoding("iso-8859-1"),
"\xa1\xa1".force_encoding("euc-jp"))
=> nil
Search the encoding with specified name. name should be a string or symbol.
Encoding.find("US-ASCII") => #<Encoding:US-ASCII>
Encoding.find(:Shift_JIS) => #<Encoding:Shift_JIS>
An ArgumentError is raised when no encoding with name. Only +Encoding.find("internal")+ however returns nil when no encoding named "internal", in other words, when Ruby has no default internal encoding.
Returns the list of loaded encodings.
Encoding.list
=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
#<Encoding:ISO-2022-JP (dummy)>]
Encoding.find("US-ASCII")
=> #<Encoding:US-ASCII>
Encoding.list
=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
#<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
Returns the locale charmap name.
Debian GNU/Linux
LANG=C
Encoding.locale_charmap => "ANSI_X3.4-1968"
LANG=ja_JP.EUC-JP
Encoding.locale_charmap => "EUC-JP"
SunOS 5
LANG=C
Encoding.locale_charmap => "646"
LANG=ja
Encoding.locale_charmap => "eucJP"
The result is higly platform dependent. So Encoding.find(Encoding.locale_charmap) may cause an error. If you need some encoding object even for unknown locale, Encoding.find("locale") can be used.
Returns true for dummy encodings. A dummy encoding is an encoding for which character handling is not properly implemented. It is used for stateful encodings.
Encoding::ISO_2022_JP.dummy? #=> true Encoding::UTF_8.dummy? #=> false
Returns a string which represents the encoding for programmers.
Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>" Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"