Utf8TryFindCodepointStart function
Tries to find the start of a valid UTF-8 codepoint in a string.
Declaration
function Utf8TryFindCodepointStart(AString: PChar; var CurPos: PChar;
out CodepointLen: Integer): BooleanArguments
AString | Pointer to the string to examine in the function. |
CurPos | Pointer to the first position in the string examined in the function. |
CodepointLen | Number of bytes in the codepoint, or 0 when invalid. |
Function result
True when the bytes at the specified position are a valid UTF-8 codepoint.
Description
Utf8TryFindCodepointStart is a
Boolean function which
tries to find the start of a valid UTF-8 codepoint at the specified position
in
AString.
The return value contains True if the bytes at the specified position are a valid UTF-8 codepoint (1 - 4 bytes). When the return value is True, the value in CurPos is updated to contain the position in AString where the UTF-8 codepoint begins. Otherwise, the value in CurPos is unchanged. Please note, when CurPos points beyond the end of AString you will get a crash!
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
