cfdcb1bb0c
Change-Id: I1c8db3d16547d8891835d0e8e849a1f53335dbf1 Reviewed-on: https://gerrit.libreoffice.org/62711 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
55 lines
1.7 KiB
Diff
55 lines
1.7 KiB
Diff
From 59a04cb70b261ad77baf671d5059a836ba339bbd Mon Sep 17 00:00:00 2001
|
|
From: Stephan Bergmann <sbergman@redhat.com>
|
|
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
|
|
<https://gerrit.libreoffice.org/#/c/62508/> "Add check for en_US.utf8 locale"
|
|
for a real-live example of issues caused by that.)
|
|
|
|
(And the <codecvt> and <locale> 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 <codecvt>
|
|
+#include <locale>
|
|
#include <sstream>
|
|
#include <fstream>
|
|
|
|
@@ -11,8 +13,6 @@
|
|
#include <boost/locale/encoding_utf.hpp>
|
|
using namespace boost;
|
|
#else
|
|
- #include <codecvt>
|
|
- #include <locale>
|
|
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<wchar_t>));
|
|
-#else
|
|
- wif.imbue(std::locale("en_US.UTF-8"));
|
|
-#endif
|
|
std::wstringstream wss;
|
|
wss << wif.rdbuf();
|
|
result = wss.str();
|
|
--
|
|
2.19.1
|
|
|