X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Flibs%2Fcp866%2Fcp866.c;h=b8ce2a451b5c6e82f2b36779c7f3ca1ce391e63e;hb=ef16dea09f87b15fc6d58fae0aa0832e0648c00e;hp=90d1bbdd643dd7c2708a4f23ec66011ce8a9f16f;hpb=1958dd7b157ada64ba81c31fb89c26ee2e95dde4;p=flatwaifu.git diff --git a/src/libs/cp866/cp866.c b/src/libs/cp866/cp866.c index 90d1bbd..b8ce2a4 100644 --- a/src/libs/cp866/cp866.c +++ b/src/libs/cp866/cp866.c @@ -1,22 +1,33 @@ +/* Copyright (C) 2020 SovietPony + * + * 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, version 3 of the License ONLY. + * + * 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 . + */ + #include "cp866.h" -int cp866_isalpha (char c) { - unsigned char ch = c; +int cp866_isalpha (int ch) { return (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A) || (ch >= 0x80 && ch <= 0xAF) || (ch >= 0xE0 && ch <= 0xF7); } -int cp866_isupper (char c) { - unsigned char ch = c; +int cp866_isupper (int ch) { return (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x80 && ch <= 0x9F) || ch == 0xF0 || ch == 0xF2 || ch == 0xF4 || ch == 0xF6; } -int cp866_islower (char c) { - unsigned char ch = c; +int cp866_islower (int ch) { return (ch >= 0x61 && ch <= 0x7A) || (ch >= 0xA0 && ch <= 0xAF) || (ch >= 0xE0 && ch <= 0xEF) || ch == 0xF1 || ch == 0xF3 || ch == 0xF5 || ch == 0xF7; } -char cp866_toupper (char c) { - unsigned char ch = c; +int cp866_toupper (int ch) { if (ch >= 0x61 && ch <= 0x7A) { return ch - 0x61 + 0x41; } else if (ch >= 0xA0 && ch <= 0xAF) { @@ -36,8 +47,7 @@ char cp866_toupper (char c) { } } -char cp866_tolower (char c) { - unsigned char ch = c; +int cp866_tolower (int ch) { if (ch >= 0x41 && ch <= 0x5A) { return ch - 0x41 + 0x61; } else if (ch >= 0x80 && ch <= 0x8F) { @@ -79,8 +89,7 @@ int cp866_strncasecmp (const char *a, const char *b, unsigned int n) { return i == 0 ? 0 : *(const unsigned char *)aa - *(const unsigned char *)bb; } -int cp866_ctou (char c) { - unsigned char ch = c; +int cp866_ctou (int ch) { switch (ch) { case 0xB0: return 0x2591; case 0xB1: return 0x2592; @@ -159,8 +168,7 @@ int cp866_ctou (char c) { } } -int cp866_ctoug (char c) { - unsigned char ch = c; +int cp866_ctoug (int ch) { switch (ch) { case 0x00: return 0x0000; case 0x01: return 0x263A;