APG
… an ABNF Parser Generator
|
A Unicode encoding/decoding object. More...
Go to the source code of this file.
Data Structures | |
struct | conv_error |
Defines the value, location and error message when a value is in error and a fatal error is issued. More... | |
struct | conv |
The conv object context. More... | |
Macros | |
Private Macros – used only by the conv object | |
#define | BASE64_LINE_LEN 76 |
#define | TAIL_CHAR 61 |
#define | NON_BYTE_MASK 0xFFFFFF00 |
#define | BYTE_MASK 0xFF |
Functions | |
void * | vpConvCtor (exception *spEx) |
The data conversion object constructor. More... | |
void | vConvDtor (void *vpCtx) |
Conversion object destructor. More... | |
void | vConvConfigureBase64 (void *vpCtx, aint uiLineLen, aint uiLineEnd) |
Configures base64 output format. More... | |
void | vConvDecode (void *vpCtx, conv_src *spSrc) |
Decode a source byte stream to 32-bit Unicode code points. More... | |
void | vConvEncode (void *vpCtx, conv_dst *spDst) |
Encode the 32-bit Unicode code points to a byte stream. More... | |
void | vConvGetCodePoints (void *vpCtx, uint32_t *uipData, uint32_t *uipDataLen) |
Access the intermediate 32-bit data following a call to vConvDecode() or vConvUseCodePoints(). More... | |
void | vConvUseCodePoints (void *vpCtx, uint32_t *uipSrc, aint uiSrcLen) |
Insert a stream of 32-bit Unicode code points as the intermediate data. More... | |
void | vConvConvert (void *vpCtx, conv_src *spSrc, conv_dst *spDst) |
Decodes and encodes in a single functions call. More... | |
A Unicode encoding/decoding object.
This object provides functions for encoding and decoding data represented in the UTF-8, UTF-16 and UTF-32 Unicode formats as well as the ISO 8859-1 format. Care has been taken to observe most (hopefully all) of the Unicode restrictions. Decoding or encoding of values outside the Unicode range is forbidden. That is characters 0xD800 to 0xDFFF and characters greater than 0x10FFFF are forbidden. Over long UTF-8 encodings are also forbidden. For example, encoding 0x7FF in three bytes instead of two is forbidden.
Conversions are done in a two-step process. A source data byte stream is first decoded into an array of 32-bit Unicode code points. This persistent array is then encoded into the destination data byte stream. Functions are available to access the intermediate 32-bit code point data and to insert 32-bit code points directly.
Source and destination byte streams may be base64 encoded.
Definition in file conv.c.
Configures base64 output format.
The default base64 output has LF (\n) line breaks at 76 characters. This function will modify that output format if called prior to vConvEncode().
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
uiLineLen | Break output lines at every uiLineLen characters. If 0 (zero), no line breaks will be added. |
uiLineEnd | Must be one of:
|
Decodes and encodes in a single functions call.
Equivalent to calling vConvDecode() and vConvEncode() in succession.
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. | |
spSrc | Pointer to the source byte stream definition. | |
[in,out] | spDst | Pointer to the destination byte stream definition. |
void vConvDecode | ( | void * | vpCtx, |
conv_src * | spSrc | ||
) |
Decode a source byte stream to 32-bit Unicode code points.
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
spSrc | Pointer to the source byte stream definition. |
void vConvDtor | ( | void * | vpCtx | ) |
Conversion object destructor.
vpCtx | A pointer to a valid context previously return from vpConvCtor(). Silently ignored if NULL. However, if non-NULL it must be a valid context pointer. The application will silently exit with BAD_CONTEXT exit code if vpCtx is invalid. |
void vConvEncode | ( | void * | vpCtx, |
conv_dst * | spDst | ||
) |
Encode the 32-bit Unicode code points to a byte stream.
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
spDst | Pointer to the destination byte stream definition. Byte stream data remains valid until another call on the context handle vpCtx. |
void vConvGetCodePoints | ( | void * | vpCtx, |
uint32_t * | uipData, | ||
uint32_t * | uipDataLen | ||
) |
Access the intermediate 32-bit data following a call to vConvDecode() or vConvUseCodePoints().
Copies the code points into the caller's array.
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
uipData | Pointer to the array to receive the data. If NULL no data is returned but the number of code points is set. |
uipDataLen | Pointer to an unsigned integer to receive the number of code points. |
void vConvUseCodePoints | ( | void * | vpCtx, |
uint32_t * | uipSrc, | ||
aint | uiSrcLen | ||
) |
Insert a stream of 32-bit Unicode code points as the intermediate data.
This data provided will be encoded with a call to vConvEncode().
vpCtx | A pointer to a valid context previously return from vpConvCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
uipSrc- | pointer to an array of 32-bit Unicode code points. |
uiSrcLen | - the number of code points. |
void* vpConvCtor | ( | exception * | spEx | ) |
The data conversion object constructor.
spEx | Pointer to a valid exception structure initialized with XCTOR(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |