Skip to content

Charset

Charset(size, empty, enable_pairs=False)

Character set.

PARAMETER DESCRIPTION
size

number of characters in character set

TYPE: int

empty

byte sequence representing an empty character

TYPE: bytes

enable_pairs

whether to enable adding character pairs

TYPE: bool DEFAULT: False

character_count property

Number of used characters.

max_index property

Maximum used character index.

add(value)

Add character at next free index.

PARAMETER DESCRIPTION
value

byte sequence representing character to add

TYPE: bytes

Returns: index of added character Raises: OverflowError: If no more characters are available.

add_pair(value1, value2, offset=None)

Add character pair at next free index pair.

PARAMETER DESCRIPTION
value1

byte sequence representing first character to add

TYPE: bytes

value2

byte sequence representing second character to add

TYPE: bytes

offset

offset between first and second character indices

TYPE: int | None DEFAULT: None

Returns: index of first added character Raises: OverflowError: If no pair of characters is available. RuntimeError: If enable_pairs is False.

add_with_index(value, index)

Add character at given index.

PARAMETER DESCRIPTION
value

byte sequence representing character to add

TYPE: bytes

index

index at which to add character

TYPE: int

RAISES DESCRIPTION
RuntimeError

If character at given index is already set

get_bytes(full=False)

Get character set as bytes.

PARAMETER DESCRIPTION
full

whether to include all characters or only up to the last used one

TYPE: bool DEFAULT: False

Returns: bytes representing the character set

get_value(index)

Get character at given index.

PARAMETER DESCRIPTION
index

index of character to get

TYPE: int

Returns: byte sequence representing character at given index