codec.codec - Palamecia/mint GitHub Wiki
Module codec.codec
Description
load codec.codec
This module provides the Codec.TextCodec class which provide the text codec interface to convert text from/to UTF-8.
Packages
Enums
Codec.Status
Status of a byte conversions.
| Constant | Value | Description ||----------|-------|-------------|
| InvalidSequence | 2 | Invalid byte sequence provided. |
| NeedMoreInput | 1 | Conversion need more bytes. |
| Success | 0 | Conversion succeed. |
Classes
Codec.TextCodec
This class provides the interface to convert text from/to UTF-8. This implementation converts raw bytes into UTF-8 characters.
Public members
| Modifiers | Member | Description |
|---|---|---|
const |
decode | Decode the characters from buffer starting at position pos. Returns an iterat... |
const |
encode | Encode the string str starting at position pos. Returns an iterator containin... |
const |
getEncoding | Returns the encoding name used by the codec. |
Private members
| Modifiers | Member | Description |
|---|---|---|
@ const |
g_lib | Global library handle. |
Descriptions
Codec.Status.InvalidSequence
2
Invalid byte sequence provided.
Codec.Status.NeedMoreInput
1
Conversion need more bytes.
Codec.Status.Success
0
Conversion succeed.
Codec.TextCodec.decode
def (self, buffer, pos)
Decode the characters from buffer starting at position pos. Returns an iterator containing the completion
status as an instance of Codec.Status and the decoded characters. If the status is Codec.Status.Success,
no more character can be decoded from the buffer. If the status is Codec.Status.NeedMoreInput more data
should be added to continue decoding. If the status is Codec.Status.InvalidSequence, decoding can not be
continued beyond this point. On any case, pos is moved to the position of the next byte to decode. The
buffer parameter should be an instance of Serializer.DataStream.
Codec.TextCodec.encode
def (self, str, pos)
Encode the string str starting at position pos. Returns an iterator containing the completion status as
an instance of Codec.Status and an instance of Serializer.DataStream containing the encoded bytes. If the
status is Codec.Status.Success, no more character need to be encoded from the string. If the status is
Codec.Status.NeedMoreInput more data should be added to continue encoding. If the status is
Codec.Status.InvalidSequence, encoding can not be continued beyond this point. On any case, pos is moved
to the position of the next byte to decode.
Codec.TextCodec.g_lib
lib ('libmint-codec')
Global library handle.
Codec.TextCodec.getEncoding
def (const self)
Returns the encoding name used by the codec.