From 59a04cb70b261ad77baf671d5059a836ba339bbd Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 30 Oct 2018 13:51:02 +0100 Subject: [PATCH] Don't depend on en_US.UTF-8 locale Instead, create locale with codecvt_utf8 facet on all platforms (even if codecvt_utf8 is deprecated since C++17). There is no guarantee that "en_US.UTF-8" is a supported locale name, so the locale constructor might throw a runtime_error. (See the discussion in the comments to "Add check for en_US.utf8 locale" for a real-live example of issues caused by that.) (And the and headers apparently need to be included always, regardless of NUMBERTEXT_BOOST.) --- src/Numbertext.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx index 8cf5198..5f05b48 100644 --- a/src/Numbertext.cxx +++ b/src/Numbertext.cxx @@ -2,6 +2,8 @@ * 2018 (c) László Németh * License: LGPL/BSD dual license */ +#include +#include #include #include @@ -11,8 +13,6 @@ #include using namespace boost; #else - #include - #include using namespace std; #endif @@ -25,11 +25,7 @@ bool readfile(const std::string& filename, std::wstring& result) std::wifstream wif(filename); if (wif.fail()) return false; -#ifdef _MSC_VER wif.imbue(std::locale(std::locale(), new std::codecvt_utf8)); -#else - wif.imbue(std::locale("en_US.UTF-8")); -#endif std::wstringstream wss; wss << wif.rdbuf(); result = wss.str(); -- 2.19.1