@@ -413,6 +413,11 @@ int main() | |||||
en_us_8bit = get_std_name("en_US.ISO8859-1"); | en_us_8bit = get_std_name("en_US.ISO8859-1"); | ||||
he_il_8bit = get_std_name("he_IL.ISO8859-8"); | he_il_8bit = get_std_name("he_IL.ISO8859-8"); | ||||
ja_jp_shiftjis = get_std_name("ja_JP.SJIS"); | 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 { | else { | ||||
en_us_8bit = "en_US.ISO8859-1"; | en_us_8bit = "en_US.ISO8859-1"; | ||||
@@ -19,6 +19,8 @@ | |||||
#include <unicode/uversion.h> | #include <unicode/uversion.h> | ||||
#endif | #endif | ||||
#include "test_locale_tools.h" | |||||
char const *env(char const *s) | char const *env(char const *s) | ||||
{ | { | ||||
@@ -101,6 +103,7 @@ int main() | |||||
}; | }; | ||||
std::cout << "- Testing locales availability on the operation system:" << std::endl; | std::cout << "- Testing locales availability on the operation system:" << std::endl; | ||||
check_locale(locales_to_check); | 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; | std::cout << "- Testing timezone and time " << std::endl; | ||||
{ | { | ||||
@@ -11,6 +11,9 @@ | |||||
#include <booster/locale/encoding.h> | #include <booster/locale/encoding.h> | ||||
#include <fstream> | |||||
#include <stdlib.h> | |||||
template<typename Char> | template<typename Char> | ||||
std::basic_string<Char> to_correct_string(std::string const &e,std::locale /*l*/) | std::basic_string<Char> 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<<japan_932; | |||||
f.close(); | |||||
} | |||||
try { | |||||
std::wfstream test; | |||||
test.imbue(std::locale(locale_name.c_str())); | |||||
test.open("test-siftjis.txt"); | |||||
// Japan in Unicode | |||||
std::wstring cmp = L"\u65e5\u672c"; | |||||
std::wstring ref; | |||||
test >> 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) | std::string get_std_name(std::string const &name,std::string *real_name = 0) | ||||
{ | { | ||||
if(has_std_locale(name)) { | if(has_std_locale(name)) { | ||||