diff --git a/app_language.cpp b/app_language.cpp index 702c2f9..f28be35 100644 --- a/app_language.cpp +++ b/app_language.cpp @@ -557,6 +557,17 @@ class lang_mgr } public: + static bool is_english_cp(int cp) + { + return cp == 37 // IBM EBCDIC US-Canada + || cp == 437 // OEM-US + || cp == 500 // IBM EBCDIC International + || cp == 1146 // IBM EBCDIC England + || cp == 1252 // ANSI west Europe + || cp == 20127 // English - US + || cp == 20285 // IBM EBCDIC English + ; + } static int get_os_code_page(void) { char* locale = setlocale(LC_ALL, ""); @@ -583,21 +594,21 @@ public: } if (!found && strrchr(locale, '.')) { - // windows: Chinese (Simplified)_China.DEFAULT_CODE_PAGE - locale = strrchr(locale, '.') + 1; - if (*locale >= '0' && *locale <= '9') - cp = atoi(locale); + if (strstr(locale, "English")) + cp = 20127; + else + { + // windows: Chinese (Simplified)_China.DEFAULT_CODE_PAGE + locale = strrchr(locale, '.') + 1; + if (*locale >= '0' && *locale <= '9') + cp = atoi(locale); + } } if(end) *end = ';'; } - if (cp == 37 // IBM EBCDIC US-Canada - || cp == 437 // OEM-US - || cp == 500 // IBM EBCDIC International - || cp == 1146 // IBM EBCDIC England - || cp == 20285 // IBM EBCDIC English - ) + if (lang_mgr::is_english_cp(cp)) cp = 20127; return cp; @@ -805,12 +816,7 @@ extern "C" } int lang_set_code_page(int cp) { - if (cp == 37 // IBM EBCDIC US-Canada - || cp == 437 // OEM-US - || cp == 500 // IBM EBCDIC International - || cp == 1146 // IBM EBCDIC England - || cp == 20285 // IBM EBCDIC English - ) + if (lang_mgr::is_english_cp(cp)) cp = 20127; return lang_mgr::instance()->set_code_page(cp);