Function
uni_compress
Compress text.
Parameters 🔗
| text | in | Text to compress. |
| text_len | in | Length of |
| text_attr | in | Attributes of |
| buffer | out | Compressed blob of bytes. |
| buffer_length | inout | Capacity of |
Return Value 🔗
| UNI_OK | On success. |
| UNI_NO_SPACE | If |
| UNI_BAD_OPERATION | If |
| UNI_BAD_ENCODING | If |
| UNI_FEATURE_DISABLED | If Unicorn was configured without support for the compression algorithm. |
Discussion 🔗
Compress text using Binary Ordered Compression for Unicode (BOCU-1) and write the results to buffer. Text is compressed based on its code points, i.e. UTF-8, 16, and 32 will compress to the same byte sequence.
The capacity of buffer is specified by buffer_length. The implementation always writes to buffer_length the total number of bytes in the fully compressed text. If the capacity of buffer is insufficient, then UNI_NO_SPACE is returned otherwise it returns UNI_OK. If buffer is NULL, then buffer_length must be zero.