Text Attribute

UNI_TRUST

Well-formed text.

Since v1.0
#define UNI_TRUST
 0x40

Discussion 🔗

Text attribute bit flag that indicates that the encoded text is well-formed.

Under normal usage Unicorn processes text with the assumption that it might be malformed. This means it performs safety checks which are redundant if the text has already been validated with uni_validate. The purpose of this flag is to inform Unicorn that it can skip redundant validation checks thereby improving performance.

By itself, this is not a valid text encoding. It is a bit flag intended to be used with a text encoding. The following code excerpt demonstrates using this flag with the UTF-8 encoding:

const char8_t *text = "Hello, World!";
int index = 0;
unichar cp;
uni_next(text, -1, UNI_UTF8 | UNI_TRUST, &index, &cp);

Usage of this flag means functions will never return UNI_BAD_ENCODING.

Some functions, like uni_norm, accept an input buffer and an output buffer. Using this flag with an output buffer will produce UNI_BAD_OPERATION.