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

UTF8CodepointToByteIndex

Finds the byte index of the n-th UTF-8 codepoint.

Declaration

Source position: lazutf8.pas line 104

function UTF8CodepointToByteIndex(

  UTF8Str: PChar;

  Len: PtrInt;

  CodepointIndex: PtrInt

):PtrInt;

Arguments

UTF8Str

  

PChar with the multi-byte UTF-8-encoded values examined in the routine.

Len

  

Length of the PChar value in UTF8Str in bytes.

CodepointIndex

  

Position of the codepoint requested in the routine. This is 1-based, like a character index in String.

Function result

Byte position where the requested UTF-8 codepoint is located, or -1 when a codepoint is not available for the index value.

Description

UTF8CodepointToByteIndex is a PtrInt function used to find the byte index in UTF8Str where the n-th UTF-8 codepoint is located. It calls UTF8CodepointStart to get a pointer to the requested codepoint position.

The return value contains the difference between the pointer offsets in each of the PChar values. The return value is -1 when a codepoint is not found at the specified position.

UTF8CodepointToByteIndex ignores BIDI mode.

See also

UTF8CodepointStart

  

Finds the n-th UTF-8 codepoint.

UTF8CharToByteIndex

  

Deprecated. Use UTF8CodepointToByteIndex instead.


Version 3.2 Generated 2024-02-25 Home