]> git.lyx.org Git - features.git/commitdiff
Always use utf-8 in scripts with Python3
authorEnrico Forestieri <forenr@lyx.org>
Thu, 25 Jan 2024 09:17:23 +0000 (10:17 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 25 Jan 2024 09:17:23 +0000 (10:17 +0100)
In order to perform a conversion of graphic format LyX generates
a python script containing the path of the original file to convert.
While Python2 needs the file in the native encoding of the OS, in
Python3 the encoding has to strictly be how announced by the first
line of a script, in our case utf-8.

src/graphics/GraphicsConverter.cpp

index c97e76663d3b1d746a37e07627d587b18d196341..669f08d2ff321c1781c808faccb8c4415732083c 100644 (file)
@@ -136,9 +136,17 @@ Converter::Impl::Impl(Converter const & parent, FileName const & doc_fname,
 
        // The conversion commands are stored in a stringstream
        ostringstream script;
-       build_script(doc_fname_.absFileName(), from_file.toFilesystemEncoding(),
-                    to_file_.toFilesystemEncoding(),
-                    from_format, to_format, script);
+       if (os::python_info()[0] == '2') {
+               build_script(doc_fname_.absFileName(),
+                            from_file.toFilesystemEncoding(),
+                            to_file_.toFilesystemEncoding(),
+                            from_format, to_format, script);
+       } else {
+               build_script(doc_fname_.absFileName(),
+                            from_file.absFileName(),
+                            to_file_.absFileName(),
+                            from_format, to_format, script);
+       }
        LYXERR(Debug::GRAPHICS, "\tConversion script:"
                   "\n--------------------------------------\n"
                << script.str()