[Overview][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'LazUTF8' (#lazutils)

Utf8TryFindCodepointStart

Tries to find the start of a valid UTF-8 codepoint in a string.

Declaration

Source position: lazutf8.pas line 98

function Utf8TryFindCodepointStart(

  AString: PChar;

  var CurPos: PChar;

  out CodepointLen: Integer

):Boolean;

function Utf8TryFindCodepointStart(

  const AString: string;

  var Index: Integer;

  out CharLen: Integer

):Boolean;

Arguments

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.

Arguments

AString

  

Pointer to the string to examine in the function.

Index

  

Initial position in the string examined in the function.

CharLen

  

Number of bytes required for the 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!

Remark: UTF8CodepointStrictSize will NOT "look" beyond the terminating #0 in a PChar, so this is safe with AnsiString values.

Version 3.2 Generated 2024-02-25 Home