From 5af7c48b76091a0a4ed19e326371eaa87790bd80 Mon Sep 17 00:00:00 2001 From: Karl Cheng Date: Fri, 17 May 2019 17:40:10 +1000 Subject: Ask Python extensions to return UTF-8 data By default, Python 2.x will encode output as ASCII to STDOUT/STDERR if the output is piped. This commit explicitly requests UTF-8 output by setting the PYTHONIOENCODING environment variable. Note this will not fix text encoding problems where the extension itself does not support Unicode properly. Refs: https://gitlab.com/inkscape/extensions/merge_requests/90 --- src/inkscape-main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/inkscape-main.cpp') diff --git a/src/inkscape-main.cpp b/src/inkscape-main.cpp index aac164b37..8473795c1 100644 --- a/src/inkscape-main.cpp +++ b/src/inkscape-main.cpp @@ -48,6 +48,9 @@ static void set_extensions_env() g_setenv("PYTHONPATH", new_pythonpath.c_str(), true); + // Python 2.x attempts to encode output as ASCII by default when sent to a pipe. + g_setenv("PYTHONIOENCODING", "UTF-8", true); + #ifdef _WIN32 // add inkscape directory to DLL search path so dynamically linked extension modules find their libraries // should be fixed in Python 3.8 (https://github.com/python/cpython/commit/2438cdf0e932a341c7613bf4323d06b91ae9f1f1) -- cgit v1.2.3