[Libreoffice-commits] core.git: external/libnumbertext lingucomponent/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 1 16:30:23 UTC 2021


 external/libnumbertext/UnpackedTarball_libnumbertext.mk |    1 
 external/libnumbertext/WinUnicodePath.patch1            |   20 ++++++++++++++++
 lingucomponent/source/numbertext/numbertext.cxx         |    4 ++-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit fd7ec8b8a5e9eec0347356b2126333dd840b5a73
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Dec 28 19:15:40 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Jan 1 17:29:42 2021 +0100

    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 at collabora.com>

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());
 }
 


More information about the Libreoffice-commits mailing list