hedgewars/uUtils.pas
changeset 15991 4ad8dd66d9d5
parent 15897 d7b53d08ad9c
child 15998 91c487e7d11d
--- a/hedgewars/uUtils.pas	Mon Jun 19 14:09:37 2023 +0200
+++ b/hedgewars/uUtils.pas	Thu Jun 22 09:13:50 2023 +0200
@@ -34,6 +34,9 @@
 procedure EscapeCharA(var a: ansistring; e: char);
 procedure UnEscapeCharA(var a: ansistring; e: char);
 
+procedure ReplaceChars(var a: shortstring; c1, c2: char);
+procedure ReplaceCharsA(var a: ansistring; c1, c2: char);
+
 function ExtractFileDir(s: shortstring) : shortstring;
 function ExtractFileName(s: shortstring) : shortstring;
 
@@ -304,6 +307,28 @@
 until (i <= 0);
 end; { UnEscapeCharA }
 
+// Replace all characters c1 with c2 in shortstring a
+procedure ReplaceChars(var a: shortstring; c1, c2: char);
+var i: LongInt;
+begin
+repeat
+    i:= Pos(c1, a);
+    if (i > 0) then
+        a[i]:= c2;
+until (i <= 0);
+end; { ReplaceChars }
+
+// Replace all characters c1 with c2 in antistring a
+procedure ReplaceCharsA(var a: ansistring; c1, c2: char);
+var i: LongInt;
+begin
+repeat
+    i:= Pos(c1, a);
+    if (i > 0) then
+        a[i]:= c2;
+until (i <= 0);
+end; { ReplaceCharsA }
+
 function EnumToStr(const en : TGearType) : shortstring; overload;
 begin
 EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en))