X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Futils.pas;h=f61035e5c4ac6a6fbf736df86b64e53901c4550e;hb=5c0e145428d60023677261d107632740cec9342b;hp=1caa1f3338c12bb30327a45ac45a4abff404199b;hpb=b0369ee9442a79c9ace3454e7e1709cd61ed6a8e;p=d2df-sdl.git diff --git a/src/shared/utils.pas b/src/shared/utils.pas index 1caa1f3..f61035e 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -81,6 +81,8 @@ function Int64ToStrComma (i: Int64): AnsiString; 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; @@ -843,6 +845,26 @@ begin 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 @@ -1339,7 +1361,7 @@ var 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); @@ -1369,7 +1391,7 @@ var 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);