From 913b749fa96f4a7d9dc0b850c06306f126e412a0 Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Mon, 7 Apr 2025 22:30:41 +0200 Subject: [PATCH] LazUtf8: correct a StartCharIndex < 1 in Utf8Insert. Reason: consistent with System.Insert(). --- components/lazutils/lazutf8.pas | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/lazutils/lazutf8.pas b/components/lazutils/lazutf8.pas index 3b97933dbf..c9f94117b8 100644 --- a/components/lazutils/lazutf8.pas +++ b/components/lazutils/lazutf8.pas @@ -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);