Always use utf-8 in scripts with Python3

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.
This commit is contained in:
Enrico Forestieri 2024-01-25 10:17:23 +01:00
parent 40c9068876
commit 48a065e89e

View File

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