CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
UTF-8 Code Point Access

Functions

_striU8Anno bool striU8Char (striter *i, int32 *out)
 
_striPeekU8Anno bool striPeekU8Char (striter *i, int32 *out)
 
bool striAdvanceU8 (striter *i, uint32 by)
 

Detailed Description

These functions operate on UTF-8 code points rather than raw bytes. They handle multi-byte sequences automatically.

Function Documentation

◆ striAdvanceU8()

bool striAdvanceU8 ( striter i,
uint32  by 
)

Advances by a specified number of UTF-8 code points

Moves forward by 'by' UTF-8 characters, automatically handling multi-byte sequences. Returns false if the end of string is reached or invalid UTF-8 is encountered.

Parameters
iIterator to advance
byNumber of UTF-8 code points to skip
Returns
true if advanced successfully, false on end of string or error

Example:

// Skip next 5 UTF-8 characters
if (striAdvanceU8(&it, 5)) {
// Successfully skipped 5 code points
}
bool striAdvanceU8(striter *i, uint32 by)

◆ striPeekU8Char()

_striPeekU8Anno bool striPeekU8Char ( striter i,
int32 *  out 
)

Retrieves the next UTF-8 code point without advancing cursor

Decodes the next UTF-8 sequence but doesn't advance the cursor. Useful for lookahead in parsers.

Parameters
iIterator to read from
outPointer to store the Unicode code point
Returns
true if a code point was decoded, false on end of string or error

Example:

int32 codepoint;
if (striPeekU8Char(&it, &codepoint)) {
// Look at next code point without consuming it
}
_striPeekU8Anno bool striPeekU8Char(striter *i, int32 *out)

◆ striU8Char()

_striU8Anno bool striU8Char ( striter i,
int32 *  out 
)

Decodes the next UTF-8 sequence into a Unicode code point and advances the cursor past the entire sequence (1-4 bytes). Returns false if the end of string is reached or invalid UTF-8 is encountered.

Parameters
iIterator to read from
outPointer to store the Unicode code point
Returns
true if a code point was decoded, false on end of string or error

Example:

striInit(&it, utf8String);
int32 codepoint;
while (striU8Char(&it, &codepoint)) {
// Process Unicode code point
}
_striU8Anno bool striU8Char(striter *i, int32 *out)
void striFinish(striter *i)
void striInit(striter *i, strref s)