Document-class: Iconv::BrokenLibrary
Detected a bug of underlying iconv(3) libray.
- returns an error without setting errno properly
Classes & Modules
- Iconv::Failure
- Iconv::BrokenLibrary
- Iconv::IllegalSequence
- Iconv::InvalidCharacter
- Iconv::InvalidEncoding
- Iconv::OutOfRange
Methods
Class
| Visibility | Signature |
|---|---|
| public | charset_map () |
| public | conv (p1, p2, p3) |
| public | iconv (...) |
| public | new (p1, p2) |
| public | open (p1, p2) |
Instance
| Visibility | Signature |
|---|---|
| public | close () |
| public | iconv (...) |
Class Method Detail
Iconv.charset_map
Returns the map from canonical name to system dependent name.
Iconv.conv(to, from, str)
Iconv.iconv(to, from, *strs)
Document-method: Iconv::iconv
Shorthand for
Iconv.open(to, from) { |cd|
(strs + [nil]).collect { |s| cd.iconv(s) }
}
Parameters
| to, from: | see Iconv.new |
| strs: | strings to be converted |
Exceptions
Exceptions thrown by Iconv.new, Iconv.open and Iconv#iconv.
Iconv.new(to, from)
Creates new code converter from a coding-system designated with from to another one designated with to.
Parameters
| to: | encoding name for destination |
| from: | encoding name for source |
Exceptions
| TypeError: | if to or from aren‘t String |
| InvalidEncoding: | if designated converter couldn‘t find out |
| SystemCallError: | if iconv_open(3) fails |
Iconv.open(to, from) { |iconv| ... }
Equivalent to Iconv.new except that when it is called with a block, it yields with the new instance and closes it, and returns the result which returned from the block.
Instance Method Detail
close()
Finishes conversion.
After calling this, calling Iconv#iconv will cause an exception, but multiple calls of close are guaranteed to end successfully.
Returns a string containing the byte sequence to change the output buffer to its initial shift state.
iconv(str, start=0, length=-1)
Document-method: Iconv#iconv
Converts string and returns the result.
- If str is a String, converts str[start, length] and returns the converted string.
- If str is nil, places converter itself into initial shift state and just returns a string containing the byte sequence to change the output buffer to its initial shift state.
- Otherwise, raises an exception.
Parameters
| str: | string to be converted, or nil |
| start: | starting offset |
| length: | conversion length; nil or -1 means whole the string from start |
Exceptions
- IconvIllegalSequence
- IconvInvalidCharacter
- IconvOutOfRange
Examples
See the Iconv documentation.