diff options
Diffstat (limited to 'DTUtility.c')
| -rw-r--r-- | DTUtility.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/DTUtility.c b/DTUtility.c index 2c1e952..5bf7ee9 100644 --- a/DTUtility.c +++ b/DTUtility.c @@ -49,18 +49,18 @@ global func EscapeString(string value) var ret = "";
for(var i = 0; i < GetLength(value); ++i)
{
- var c = GetChar(value, i);
- if(c == 34) // "
+ var c = value[i];
+ if(c == "\"")
{
ret ..= "\\\"";
}
- else if(c == 92) // \
+ else if(c == "\\")
{
ret ..= "\\\\";
}
else
{
- ret = Format("%s%c", ret, c);
+ ret ..= c;
}
}
return ret;
@@ -107,9 +107,6 @@ global func CreateBitField(string prefix, array flags) Log("%s%c%c", log, 10, 10);
}
-// pos >= 0 => begin at pos | pos < 0 => begin at GetLength(string) - pos
-// count = 0 => replace all | count > 0 replace a maximum of count occurences from starting from pos
-
global func Lowercase(int c)
{
if((c >= 65 && c <= 90) || (c >= 192 && c <= 214) || (c >= 216 && c <= 221)) return c + 32;
@@ -154,6 +151,8 @@ global func StringConcatenate(array strings) return ret;
}
+// pos >= 0 => begin at pos | pos < 0 => begin at GetLength(string) - pos
+// count = 0 => replace all | count > 0 replace a maximum of count occurences starting from pos
global func MultiStringReplace(find, strings, replace, bool caseInsensitive, int count, int pos, int maxpos)
{
var returnString = false;
@@ -195,7 +194,7 @@ global func StringReplace(string find, string string, string replace, bool caseI for(var i = 0; i < pos; ++i)
{
- ret = Format("%s%c", ret, GetChar(string, i));
+ ret ..= string[i];
}
var match = 0;
@@ -204,12 +203,11 @@ global func StringReplace(string find, string string, string replace, bool caseI for(i = pos; i + GetLength(find) - match - 1 < maxpos && count != 0; ++i)
{
- var c = GetChar(string, i);
- if(CaseInsensitive(c, !caseInsensitive) == CaseInsensitive(GetChar(find, match), !caseInsensitive))
+ if(CaseInsensitive(GetChar(string, i), !caseInsensitive) == CaseInsensitive(GetChar(find, match), !caseInsensitive))
{
if(++match == GetLength(find))
{
- ret = StringConcatenate([ret, replace]);
+ ret ..= replace;
match = 0;
--count;
}
@@ -220,17 +218,17 @@ global func StringReplace(string find, string string, string replace, bool caseI {
for(var j = i - match; j < i; ++j)
{
- ret = Format("%s%c", ret, GetChar(string, j));
+ ret ..= string[j];
}
}
match = 0;
- ret = Format("%s%c", ret, GetChar(string, i));
+ ret ..= string[i];
}
}
for(i -= match; i < GetLength(string); ++i)
{
- ret = Format("%s%c", ret, GetChar(string, i));
+ ret ..= string[i];
}
return ret;
|
