diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 1caa1f3338c12bb30327a45ac45a4abff404199b..f61035e5c4ac6a6fbf736df86b64e53901c4550e 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
function UpCase1251 (ch: Char): Char;
function LoCase1251 (ch: Char): Char;
+function toLowerCase1251 (const s: AnsiString): AnsiString;
+
// `true` if strings are equal; ignoring case for cp1251
function StrEquCI1251 (const s0, s1: AnsiString): Boolean;
end;
+function toLowerCase1251 (const s: AnsiString): AnsiString;
+var
+ f: Integer;
+ ch: AnsiChar;
+begin
+ for ch in s do
+ begin
+ if (ch <> LoCase1251(ch)) then
+ begin
+ result := '';
+ SetLength(result, Length(s));
+ for f := 1 to Length(s) do result[f] := LoCase1251(s[f]);
+ exit;
+ end;
+ end;
+ // nothing to do
+ result := s;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
// utils
// `ch`: utf8 start
xpos := High(strbuf);
strbuf[xpos] := #0; Dec(xpos);
repeat
- if hex then
+ if not hex then
begin
strbuf[xpos] := AnsiChar((n mod 10)+48);
Dec(xpos);
xpos := High(strbuf);
strbuf[xpos] := #0; Dec(xpos);
repeat
- if hex then
+ if not hex then
begin
strbuf[xpos] := AnsiChar((n mod 10)+48);
Dec(xpos);