From 5dff0a1c6ee17ccdb943903ae5da0617b6504f16 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sat, 19 Feb 2022 17:48:48 +0300 Subject: [PATCH 1/2] better charset detection --- far2l/src/locale/DetectCodepage.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/far2l/src/locale/DetectCodepage.cpp b/far2l/src/locale/DetectCodepage.cpp index b4dee2c68..8c65e2fbc 100644 --- a/far2l/src/locale/DetectCodepage.cpp +++ b/far2l/src/locale/DetectCodepage.cpp @@ -33,6 +33,9 @@ static int TranslateUDCharset(const char *cs) return atoi(cs + 2); } + if (strncasecmp(cs, "IBM", 3) == 0 && IsDecimalNumber(cs + 3)) { + return atoi(cs + 3); + } if (!strcasecmp(cs, "UTF16-LE") || !strcasecmp(cs, "UTF16")) return CP_UTF16LE; @@ -46,10 +49,10 @@ static int TranslateUDCharset(const char *cs) return CP_UTF8; if (!strcasecmp(cs, "UTF-7")) return CP_UTF7; - if (!strcasecmp(cs, "IBM855")) - return 855; - if (!strcasecmp(cs, "IBM866")) - return 866; +// if (!strcasecmp(cs, "IBM855")) +// return 855; +// if (!strcasecmp(cs, "IBM866")) +// return 866; if (!strcasecmp(cs, "KOI8-R")) return 20866; if (!strcasecmp(cs, "KOI8-U")) From 4555358636b3d7d36aa540a7e45c252a07d6a8a8 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 20 Feb 2022 00:19:46 +0300 Subject: [PATCH 2/2] cosmetic --- far2l/src/locale/DetectCodepage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/far2l/src/locale/DetectCodepage.cpp b/far2l/src/locale/DetectCodepage.cpp index 8c65e2fbc..a98291801 100644 --- a/far2l/src/locale/DetectCodepage.cpp +++ b/far2l/src/locale/DetectCodepage.cpp @@ -33,7 +33,7 @@ static int TranslateUDCharset(const char *cs) return atoi(cs + 2); } - if (strncasecmp(cs, "IBM", 3) == 0 && IsDecimalNumber(cs + 3)) { + if (strncasecmp(cs, "IBM", 3) == 0 && IsDecimalNumber(cs + 3)) { return atoi(cs + 3); }