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

This commit is contained in:
Bart 2025-04-07 22:48:51 +02:00
parent 913b749fa9
commit bad60c010b

View File

@ -1194,7 +1194,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;