sdlStepBackUtf8 function
Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
This will go to the start of the previous Unicode codepoint in the string,
move *pstr
to that location and return that codepoint.
If *pstr
is already at the start of the string), it will not advance
*pstr
at all.
Generally this function is called in a loop until it returns zero, adjusting its parameter each iteration.
If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT.
Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.
\param start a pointer to the beginning of the UTF-8 string. \param pstr a pointer to a UTF-8 string pointer to be read and adjusted. \returns the previous Unicode codepoint in the string.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.6.
extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepBackUTF8(const char *start, const char **pstr)
Implementation
int sdlStepBackUtf8(String? start, Pointer<Pointer<Int8>> pstr) {
final sdlStepBackUtf8LookupFunction = libSdl3.lookupFunction<
Uint32 Function(Pointer<Utf8> start, Pointer<Pointer<Int8>> pstr),
int Function(Pointer<Utf8> start,
Pointer<Pointer<Int8>> pstr)>('SDL_StepBackUTF8');
final startPointer = start != null ? start.toNativeUtf8() : nullptr;
final result = sdlStepBackUtf8LookupFunction(startPointer, pstr);
calloc.free(startPointer);
return result;
}