Next: , Up: Elementary string functions on NUL terminated strings   [Contents][Index]


4.5.1 Iterating over a NUL terminated Unicode string

The following functions inspect and return details about the first character in a Unicode string.

Function: int u8_strmblen (const uint8_t *s)
Function: int u16_strmblen (const uint16_t *s)
Function: int u32_strmblen (const uint32_t *s)

Returns the length (number of units) of the first character in s. Returns 0 if it is the NUL character. Returns -1 upon failure.

Function: int u8_strmbtouc (ucs4_t *puc, const uint8_t *s)
Function: int u16_strmbtouc (ucs4_t *puc, const uint16_t *s)
Function: int u32_strmbtouc (ucs4_t *puc, const uint32_t *s)

Returns the length (number of units) of the first character in s, putting its ucs4_t representation in *puc. Returns 0 if it is the NUL character. Returns -1 upon failure.

Function: const uint8_t * u8_next (ucs4_t *puc, const uint8_t *s)
Function: const uint16_t * u16_next (ucs4_t *puc, const uint16_t *s)
Function: const uint32_t * u32_next (ucs4_t *puc, const uint32_t *s)

Forward iteration step. Advances the pointer past the next character, or returns NULL if the end of the string has been reached. Puts the character’s ucs4_t representation in *puc.

The following function inspects and returns details about the previous character in a Unicode string.

Function: const uint8_t * u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
Function: const uint16_t * u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start)
Function: const uint32_t * u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start)

Backward iteration step. Advances the pointer to point to the previous character (the one that ends at s), or returns NULL if the beginning of the string (specified by start) had been reached. Puts the character’s ucs4_t representation in *puc. Note that this function works only on well-formed Unicode strings.


Next: Length of a NUL terminated Unicode string, Up: Elementary string functions on NUL terminated strings   [Contents][Index]