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

UTF8Insert

Inserts the specified UTF-8 values into a string at the specified character position.

Declaration

Source position: lazutf8.pas line 121

procedure UTF8Insert(

  const source: Utf8String;

  var s: Utf8String;

  StartCharIndex: PtrInt

);

procedure UTF8Insert(

  const source: string;

  var s: string;

  StartCharIndex: PtrInt

);

Arguments

source

  

String with the values inserted in the routine.

s

  

String where the values from source are inserted.

StartCharIndex

  

Starting character position (1-based) where the inserted values from source are stored in s.

Arguments

source

  

String with the values inserted in the routine.

s

  

String where the values from source are inserted.

StartCharIndex

  

Starting character position (1-based) where the inserted values from source are stored in s.

Description

UTF8Insert inserts the specified values into a string at the specified character position. UTF8Insert is an overloaded procedure. The variants allow the string arguments to be specified as either String or UTF8String types.

source is the UTF-8-encoded values inserted in the routine.

s is the string where the values from source are inserted at the specified character position.

The value in StartCharIndex starts at 1, and represents the n-th codepoint (or character) in the destination string (s) where the values are inserted. If StartCharIndex contains a value less than 1, it is converted to the value 1 (just like in the RTL Insert routine).

UTF8Insert calls UTF8CodepointStart to determine the position in s where the codepoint represented by StartCharIndex is located. The RTL Insert routine is called to insert the UTF-8-encoded values from source into s at the required position. If s is an empty UTF-8 string or the specified character index does not exist, the value in source is appended to the value in s.

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), the value is appended when the character index is not found.

See also

UTF8CodepointStart

  

Finds the n-th UTF-8 codepoint.

UTF8Delete

  

Deletes characters (or codepoints) in a UTF-8-encoded string.

UTF8Pos

  

Returns the character index where the search text starts in the string.


Version 4.0 Generated 2025-05-03 Home