summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-12-28 19:15:40 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-01-01 17:29:42 +0100
commitfd7ec8b8a5e9eec0347356b2126333dd840b5a73 (patch)
tree9d824785ce587c8ca0a8dc0192ae546de4a2e047 /external
parent02eaea1f93b516e35d4583158f87b2222fdd2640 (diff)
Use Unicode paths on Windows in libnumbertext
Change-Id: I02790afc314c8633a24dbf23001f3d5cffe169b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108478 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'external')
-rw-r--r--external/libnumbertext/UnpackedTarball_libnumbertext.mk1
-rw-r--r--external/libnumbertext/WinUnicodePath.patch120
2 files changed, 21 insertions, 0 deletions
diff --git a/external/libnumbertext/UnpackedTarball_libnumbertext.mk b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
index d2efd2f852c3..48cd2a9a273d 100644
--- a/external/libnumbertext/UnpackedTarball_libnumbertext.mk
+++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libnumbertext,1))
$(eval $(call gb_UnpackedTarball_add_patches,libnumbertext, \
external/libnumbertext/MSVCNonBMPBug.patch1 \
+ external/libnumbertext/WinUnicodePath.patch1 \
))
# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/WinUnicodePath.patch1 b/external/libnumbertext/WinUnicodePath.patch1
new file mode 100644
index 000000000000..24a0bd5800d1
--- /dev/null
+++ b/external/libnumbertext/WinUnicodePath.patch1
@@ -0,0 +1,20 @@
+To allow opening files on Unicode paths on Windpws, expect passed 8-bit
+strings to be UTF-8-encoded, and convert them to wchar_t. Fallback to
+ACP strings for backward compatibility.
+
+diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
+--- a/src/Numbertext.cxx
++++ b/src/Numbertext.cxx
+@@ -27,7 +27,11 @@
+ bool readfile(const std::string& filename, std::wstring& result)
+ {
+ #ifdef _WIN32
+- std::ifstream ifs(filename);
++ // First try to convert from UTF-8
++ std::ifstream ifs(Numbertext::string2wstring(filename));
++ // Fallback to ACP string for backward compatibility
++ if (ifs.fail())
++ ifs.open(filename);
+ if (ifs.fail())
+ return false;
+ std::stringstream ss;