LazUtf8: Fix Utf8Insert for StartCharIndex > Utf8Length(s)+1. Reason: consistent with System.Insert().

(cherry picked from commit bad60c010b)
This commit is contained in:
Bart 2025-04-07 22:48:51 +02:00 committed by Maxim Ganetsky
parent 5c7fcf1fc0
commit 18e40b905b

View File

@ -1201,7 +1201,9 @@ begin
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);
Insert(source, s, StartBytePos-PChar(s)+1)
else
s := s + source; // StartCharIndex > Utf8Length(s) + 1, consistent with System.Insert
end;
function UTF8StringReplace(const S, OldPattern, NewPattern: String;