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

UTF8Copy

Copies the specified number of codepoints from the UTF-8-encoded string starting at the specified character index.

Declaration

Source position: lazutf8.pas line 118

function UTF8Copy(

  const s: string;

  StartCharIndex: PtrInt;

  CharCount: PtrInt

):string;

Arguments

s

  

String with values to copy in the function.

StartCharIndex

  

Initial character position for the copy operation. Uses index positions starting at 1 (just like the String type).

CharCount

  

Number of characters (codepoints) to copy in the function.

Function result

String with codepoints copied from the specified source.

Description

UTF8Copy is a String function used copy to UTF-8-encoded values from s starting at the position in StartCharIndex. A value in StartCharIndex starts at 1 (one). If a value is provided that is less than 1, it is convert to 1 (just like in the RTL Copy routine). CharCount specifies the number of multi-byte characters (or codepoints) to include in the return value. The return value is an empty string ('') when s is not a valid UTF-8-encoded string.

UTF8Copy behaves like a substring function.

Remark: Modified in LazUtils version 4.0 to ensure that StartCharIndex starts at 1 (for String-style indexing) and not 0 (for PChar-style indexing).

Version 4.0 Generated 2025-05-03 Home