Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / external / libnumbertext / 0001-Don-t-depend-on-en_US.UTF-8-locale.patch
blob4a454a098007d1adbf82a84ecfb2d205be7d2fc2
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.)
15 ---
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
23 @@ -2,6 +2,8 @@
24 * 2018 (c) László Németh
25 * License: LGPL/BSD dual license */
27 +#include <codecvt>
28 +#include <locale>
29 #include <sstream>
30 #include <fstream>
32 @@ -11,8 +13,6 @@
33 #include <boost/locale/encoding_utf.hpp>
34 using namespace boost;
35 #else
36 - #include <codecvt>
37 - #include <locale>
38 using namespace std;
39 #endif
41 @@ -25,11 +25,7 @@ bool readfile(const std::string& filename, std::wstring& result)
42 std::wifstream wif(filename);
43 if (wif.fail())
44 return false;
45 -#ifdef _MSC_VER
46 wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t>));
47 -#else
48 - wif.imbue(std::locale("en_US.UTF-8"));
49 -#endif
50 std::wstringstream wss;
51 wss << wif.rdbuf();
52 result = wss.str();
53 --
54 2.19.1