Function

uni_decompress

Decompress text.

Since v1.0
unistat uni_decompress(
const uint8_t *buffer, size_t buffer_length, void *text, unisize *text_len, uniattr text_attr)

Parameters 🔗

buffer in

Blob of bytes to decompress.

buffer_length in

Length of buffer.

text out

Compressed blob of bytes.

text_len inout

Capacity of text on input; number of bytes in buffer when compressed on output.

text_attr in

Attributes of the decompressed text (does not need to match the uncompressed encoding).

Return Value 🔗

UNI_OK

On success.

UNI_NO_SPACE

If text is not large enough.

UNI_BAD_OPERATION

If buffer is NULL, text is NULL and text_len is non-zero.

UNI_FEATURE_DISABLED

If Unicorn was configured without support for the compression algorithm.

Discussion 🔗

Decompress buffer and write the result to text. The encoding of text_attr need not match the encoding of the original uncompressed text.

The capacity of text is specified by text_len. If text is not NULL, then the implementation writes to text_len the total number of code units written to text. If the capacity of text is insufficient, then UNI_NO_SPACE is returned otherwise it returns UNI_OK.

If text is NULL, then text_len must be zero and the implementation writes to text_len the number of code units in the fully decompressed text and returns UNI_OK. Call the function this way to compute the total length of the uncompressed text before calling it again with a sufficiently sized buffer.

See Also 🔗