diff --git a/booster/lib/locale/test/test_codepage.cpp b/booster/lib/locale/test/test_codepage.cpp index a1f423d..ffc5060 100644 --- a/booster/lib/locale/test/test_codepage.cpp +++ b/booster/lib/locale/test/test_codepage.cpp @@ -413,6 +413,11 @@ int main() en_us_8bit = get_std_name("en_US.ISO8859-1"); he_il_8bit = get_std_name("he_IL.ISO8859-8"); ja_jp_shiftjis = get_std_name("ja_JP.SJIS"); + if(!test_std_supports_SJIS_codecvt(ja_jp_shiftjis)) + { + std::cout << "Warning: detected unproper support of " << ja_jp_shiftjis << " locale, disableling it" << std::endl; + ja_jp_shiftjis = ""; + } } else { en_us_8bit = "en_US.ISO8859-1"; diff --git a/booster/lib/locale/test/test_config.cpp b/booster/lib/locale/test/test_config.cpp index 05441ab..0e4efd6 100644 --- a/booster/lib/locale/test/test_config.cpp +++ b/booster/lib/locale/test/test_config.cpp @@ -19,6 +19,8 @@ #include #endif +#include "test_locale_tools.h" + char const *env(char const *s) { @@ -101,6 +103,7 @@ int main() }; std::cout << "- Testing locales availability on the operation system:" << std::endl; check_locale(locales_to_check); + std::cout << "--- Testing Japanese_Japan.932 is working: " << test_std_supports_SJIS_codecvt("Japanese_Japan.932") << std::endl; std::cout << "- Testing timezone and time " << std::endl; { diff --git a/booster/lib/locale/test/test_locale_tools.h b/booster/lib/locale/test/test_locale_tools.h index 06f7540..38ed17b 100644 --- a/booster/lib/locale/test/test_locale_tools.h +++ b/booster/lib/locale/test/test_locale_tools.h @@ -11,6 +11,9 @@ #include +#include +#include + template std::basic_string to_correct_string(std::string const &e,std::locale /*l*/) { @@ -35,6 +38,34 @@ bool has_std_locale(std::string const &name) } } +inline bool test_std_supports_SJIS_codecvt(std::string const &locale_name) +{ + bool res = true; + { + // Japan in Shift JIS/cp932 + char const *japan_932 = "\x93\xfa\x96\x7b"; + std::ofstream f("test-siftjis.txt"); + f<> ref; + res = ref == cmp; + } + catch(std::exception const &) + { + res = false; + } + remove("test-siftjis.txt"); + return res; +} + std::string get_std_name(std::string const &name,std::string *real_name = 0) { if(has_std_locale(name)) {