summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--external/libnumbertext/UnpackedTarball_libnumbertext.mk1
-rw-r--r--external/libnumbertext/WinUnicodePath.patch120
-rw-r--r--lingucomponent/source/numbertext/numbertext.cxx4
3 files changed, 24 insertions, 1 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;
diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
index dfc11a1fbb85..cb8e913bf571 100644
--- a/lingucomponent/source/numbertext/numbertext.cxx
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -100,10 +100,12 @@ void NumberText_Impl::EnsureInitialized()
osl::FileBase::getSystemPathFromFileURL(aURL, aPhysPath);
#ifdef _WIN32
aPhysPath += "\\";
+ const rtl_TextEncoding eEnc = RTL_TEXTENCODING_UTF8;
#else
aPhysPath += "/";
+ const rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
#endif
- OString path = OUStringToOString(aPhysPath, osl_getThreadTextEncoding());
+ OString path = OUStringToOString(aPhysPath, eEnc);
m_aNumberText.set_prefix(path.getStr());
}