[Libreoffice-commits] core.git: helpcompiler/inc

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 1 17:19:19 UTC 2021


 helpcompiler/inc/HelpCompiler.hxx |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

New commits:
commit fed54ff3f2b54ad91650154546a1c5f55d67b859
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Dec 28 19:29:43 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Jan 1 18:18:38 2021 +0100

    Use Unicode paths on Windows for help compiler
    
    Change-Id: I4c7a478d457f5e2f5b69a366736c63dec1b31cbb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108482
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx
index 87390aeedc7e..541f4bc078e5 100644
--- a/helpcompiler/inc/HelpCompiler.hxx
+++ b/helpcompiler/inc/HelpCompiler.hxx
@@ -59,21 +59,19 @@ namespace fs
         {
             OUString sWorkingDir;
             osl_getProcessWorkingDir(&sWorkingDir.pData);
-            OString tmp(in.c_str());
-            OUString ustrSystemPath(OStringToOUString(tmp, osl_getThreadTextEncoding()));
+            OUString ustrSystemPath(OStringToOUString(in, FileNameEnc()));
             osl::File::getFileURLFromSystemPath(ustrSystemPath, data);
             (void)osl::File::getAbsoluteFileURL(sWorkingDir, data, data);
         }
         path(const std::string &FileURL)
         {
-            OString tmp(FileURL.c_str());
-            data = OStringToOUString(tmp, osl_getThreadTextEncoding());
+            data = OStringToOUString(FileURL, FileNameEnc());
         }
         std::string native_file_string() const
         {
             OUString ustrSystemPath;
             osl::File::getSystemPathFromFileURL(data, ustrSystemPath);
-            OString tmp(OUStringToOString(ustrSystemPath, osl_getThreadTextEncoding()));
+            OString tmp(OUStringToOString(ustrSystemPath, FileNameEnc()));
             HCDBG(std::cerr << "native_file_string is " << tmp.getStr() << std::endl);
             return std::string(tmp.getStr());
         }
@@ -96,8 +94,7 @@ namespace fs
             path ret(*this);
             HCDBG(std::cerr << "orig was " <<
                 OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
-            OString tmp(in.c_str());
-            OUString ustrSystemPath(OStringToOUString(tmp, osl_getThreadTextEncoding()));
+            OUString ustrSystemPath(OStringToOUString(in, FileNameEnc()));
             ret.data += "/" + ustrSystemPath;
             HCDBG(std::cerr << "final is " <<
                 OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
@@ -105,11 +102,19 @@ namespace fs
         }
         void append(const char *in)
         {
-            OString tmp(in);
-            OUString ustrSystemPath(OStringToOUString(tmp, osl_getThreadTextEncoding()));
+            OUString ustrSystemPath(OStringToOUString(in, FileNameEnc()));
             data += ustrSystemPath;
         }
         void append(const std::string &in) { append(in.c_str()); }
+
+    private:
+#ifdef _WIN32
+        // On Windows, libxslt and libxml use UTF-8 path strings
+        static constexpr rtl_TextEncoding FileNameEnc() { return RTL_TEXTENCODING_UTF8; }
+#else
+        static rtl_TextEncoding FileNameEnc() { return osl_getThreadTextEncoding(); }
+#endif
+
     };
 
     void create_directory(const fs::path& indexDirName);


More information about the Libreoffice-commits mailing list