1 From 59a04cb70b261ad77baf671d5059a836ba339bbd Mon Sep 17 00:00:00 2001
2 From: Stephan Bergmann <sbergman@redhat.com>
3 Date: Tue, 30 Oct 2018 13:51:02 +0100
4 Subject: [PATCH] Don't depend on en_US.UTF-8 locale
6 Instead, create locale with codecvt_utf8 facet on all platforms (even if
7 codecvt_utf8 is deprecated since C++17). There is no guarantee that
8 "en_US.UTF-8" is a supported locale name, so the locale constructor might throw
9 a runtime_error. (See the discussion in the comments to
10 <https://gerrit.libreoffice.org/#/c/62508/> "Add check for en_US.utf8 locale"
11 for a real-live example of issues caused by that.)
13 (And the <codecvt> and <locale> headers apparently need to be included always,
14 regardless of NUMBERTEXT_BOOST.)
16 src/Numbertext.cxx | 8 ++------
17 1 file changed, 2 insertions(+), 6 deletions(-)
19 diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
20 index 8cf5198..5f05b48 100644
21 --- a/src/Numbertext.cxx
22 +++ b/src/Numbertext.cxx
24 * 2018 (c) László Németh
25 * License: LGPL/BSD dual license */
33 #include <boost/locale/encoding_utf.hpp>
34 using namespace boost;
41 @@ -25,11 +25,7 @@ bool readfile(const std::string& filename, std::wstring& result)
42 std::wifstream wif(filename);
46 wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t>));
48 - wif.imbue(std::locale("en_US.UTF-8"));
50 std::wstringstream wss;