LazUtf8: correct a StartCharIndex < 1 in Utf8Insert. Reason: consistent with System.Insert().

This commit is contained in:
Bart 2025-04-07 22:30:41 +02:00
parent 06a86413f2
commit 913b749fa9

View File

@ -1190,6 +1190,8 @@ procedure UTF8Insert(const source: String; var s: String; StartCharIndex: PtrInt
var
StartBytePos: PChar;
begin
if StartCharIndex < 1 then
StartCharIndex := 1; //Insert() does this correction too
StartBytePos:=UTF8CodepointStart(PChar(s),length(s),StartCharIndex-1);
if StartBytePos <> nil then
Insert(source, s, StartBytePos-PChar(s)+1);