X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Futils.pas;h=253e838961316e5bd5e2b19595ba10d7760e033a;hb=2fc1afb15bf2071e20e5183d9a610d70632d06a1;hp=f9d8ffafd927c2715bdf5e81907e0a752c4ae020;hpb=ffd525f425556f81296ad45b6011791ffffb6eaf;p=d2df-sdl.git diff --git a/src/shared/utils.pas b/src/shared/utils.pas index f9d8ffa..253e838 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -1,3 +1,18 @@ +(* Copyright (C) DooM 2D:Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) {$MODE DELPHI} unit utils; @@ -20,6 +35,7 @@ function addWadExtension (fn: AnsiString): AnsiString; function Int64ToStrComma (i: Int64): AnsiString; function UpCase1251 (ch: Char): Char; +function LoCase1251 (ch: Char): Char; // `true` if strings are equal; ignoring case for cp1251 function StrEquCI1251 (const s0, s1: AnsiString): Boolean; @@ -154,6 +170,30 @@ begin end; +function LoCase1251 (ch: Char): Char; +begin + if ch < #128 then + begin + if (ch >= 'A') and (ch <= 'Z') then Inc(ch, 32); + end + else + begin + if (ch >= #192) and (ch <= #223) then + begin + Inc(ch, 32); + end + else + begin + case ch of + #168, #170, #175: Inc(ch, 16); + #161, #178: Inc(ch); + end; + end; + end; + result := ch; +end; + + function StrEquCI1251 (const s0, s1: AnsiString): Boolean; var i: Integer;