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

UTF8LengthFast

Fast version of UTF8Length.

Declaration

Source position: lazutf8.pas line 84

function UTF8LengthFast(

  const s: string

):PtrInt;

function UTF8LengthFast(

  p: PChar;

  ByteCount: PtrInt

):PtrInt;

Arguments

s

  

String with UTF-8-encoded values.

Function result

Number of codepoints in the string.

Arguments

p

  

Pointer to the String with UTF-8-encoded values.

ByteCount

  

Number of byte values in the UTF-8-encoded string.

Description

UTF8LengthFast is an overloaded PtrInt function used to get the length of a UTF-8-encoded string in codepoints. UTF8LengthFast is the fast version of UTF8Length. It does not call the UTF8CodepointSize function. The UTF-8-encoded string data is assumed to be valid. The native data size for the CPU is used to process blocks of UTF-8-encoded data. For a 64-bit CPU, this means that 8 bytes are read and processed at once.

The overloaded variants allow the UTF-8-encoded data to be specified as either a String type, or a null-terminated PChar type. Internally, the String-based variant casts its data to a PChar type and calls the overloaded variant.

UTF8LengthFast is a Free Pascal implementation of the C routine provided by Colin Percival:

Even faster UTF-8 character counting

See also

UTF8Length

  

Gets the length of a UTF-8-encoded string in codepoints.


Version 3.2 Generated 2024-02-25 Home