Skip to content

string_encoding_utils

encode_string(bytes)

Encodes a string by inverting the bytes and then reversing them.

This is an in-place operation.

Parameters:

Name Type Description Default
bytes bytearray

The byte array to encode.

required
Source code in src/eolib/data/string_encoding_utils.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def encode_string(bytes: bytearray) -> None:
    """
    Encodes a string by inverting the bytes and then reversing them.

    This is an in-place operation.

    Args:
        bytes (bytearray): The byte array to encode.
    """
    _invert_characters(bytes)
    bytes.reverse()

decode_string(bytes)

Decodes a string by reversing the bytes and then inverting them.

This is an in-place operation.

Parameters:

Name Type Description Default
bytes bytearray

The byte array to decode.

required
Source code in src/eolib/data/string_encoding_utils.py
14
15
16
17
18
19
20
21
22
23
24
def decode_string(bytes: bytearray) -> None:
    """
    Decodes a string by reversing the bytes and then inverting them.

    This is an in-place operation.

    Args:
        bytes (bytearray): The byte array to decode.
    """
    bytes.reverse()
    _invert_characters(bytes)