codec.iconv - Palamecia/mint GitHub Wiki
Module
load codec.iconv
This module provides the Codec.Iconv class which provide a codec to convert text using the iconv backend.
Packages
Enums
Codec.Iconv.State
State of a byte conversion. This type is used by the Codec.Iconv.decodeChar, Codec.Iconv.decode and Codec.Iconv.encode methods to make the conversion.
Constant | Value | Description |
---|---|---|
Invalid | 1 |
Invalid byte sequence. |
NeedMore | 2 |
Conversion need more bytes. |
Success | 0 |
Conversion succed. |
Classes
Codec.Iconv
This class use the iconv backend to convert text from and to others encodings.
Example:
load system.file
load codec.iconv
if file = System.open(path) {
file.setCodec(Codec.Iconv('ISO-8859-1'))
/// ...
}
Members
Modifiers | Member | Description |
---|---|---|
+ class |
InvalidByteSequence | This class provides the context of an invalid byte sequence exception. |
+ enum |
State | State of a byte conversion. This type is used by the Codec.Iconv.decodeChar, ... |
- final |
d_ptr | Object data. |
+ const |
decode | Returns whole content decoded from the source encoding to UTF-8. The stream ... |
+ const |
decodeChar | Returns one character decoded from the source encoding to UTF-8. The readCa ... |
+ const |
decodeLine | Returns one line decoded from the source encoding to UTF-8. The readCallbac ... |
+ const |
decodeLines | Returns each line decoded from the source encoding to UTF-8. The readCallba ... |
+ const |
decodeWord | Returns one word decoded from the source encoding to UTF-8. The readCallbac ... |
+ const |
encode | Returns an instance of Serializer.DataStream containing the buffer encoded ... |
- @ |
g_lib | Global library handle. |
+ const |
new | Create a new instance of the codec. The encoding parameter must be a valid ... |
Codec.Iconv.InvalidByteSequence
This class provides the context of an invalid byte sequence exception.
Inherits
Members
Modifiers | Member | Description |
---|---|---|
+ const |
new | Create a new instance of the exception for the given stream byte sequence. |
- final |
stream | Internal byte sequence. |
+ const |
toString | Returns the exception informations as a string. |
Descriptions
Codec.Iconv.InvalidByteSequence.new
def (self, stream)
Create a new instance of the exception for the given stream
byte
sequence.
Codec.Iconv.InvalidByteSequence.stream
null
Internal byte sequence.
Codec.Iconv.InvalidByteSequence.toString
def (const self)
Returns the exception informations as a string.
Codec.Iconv.State.Invalid
1
Invalid byte sequence.
Codec.Iconv.State.NeedMore
2
Conversion need more bytes.
Codec.Iconv.State.Success
0
Conversion succed.
Codec.Iconv.d_ptr
null
Object data.
Codec.Iconv.decode
def (self, stream)
Returns whole content decoded from the source encoding to UTF-8. The
stream
parameter must be an instance of Serializer.DataStream
containing the source. If the byte sequence can not be decoded with the
source encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.decodeChar
def (self, readCallback)
Returns one character decoded from the source encoding to UTF-8. The
readCallback
parameter must be a function that provide the next byte
of the source. If the byte sequence can not be decoded with the source
encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.decodeLine
def (self, readCallback)
Returns one line decoded from the source encoding to UTF-8. The
readCallback
parameter must be a function that provide the next byte
of the source. If the byte sequence can not be decoded with the source
encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.decodeLines
def (self, readCallback)
Returns each line decoded from the source encoding to UTF-8. The
readCallback
parameter must be function that provide the next byte
of the source. If the byte sequence can not be decoded with the source
encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.decodeWord
def (self, readCallback)
Returns one word decoded from the source encoding to UTF-8. The
readCallback
parameter must be a function that provide the next byte
of the source. If the byte sequence can not be decoded with the source
encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.encode
def (self, buffer)
Returns an instance of Serializer.DataStream containing the buffer
encoded to the source encoding. If the buffer can not be encoded to the
target encoding, an instance of InvalidByteSequence is raised.
Codec.Iconv.g_lib
lib ('libmint-codec')
Global library handle.
Codec.Iconv.new
def (self, encoding)
Create a new instance of the codec. The encoding
parameter must be a
valid encoding name supported by iconv.