Use system locale to decode subprocess output

This commit is contained in:
Florian Bruhin 2017-12-13 20:09:56 +01:00
parent 07d07c7fae
commit 922b1e8f10
2 changed files with 8 additions and 4 deletions

View File

@ -104,6 +104,8 @@ Changed
- The default font size for the UI got bumped up from 8pt to 10pt.
- Improved matching in the completion: The words entered are now matched in any
order, and mixed matches on URL/tite are possible.
- The system's default encoding (rather than UTF-8) is now used to decode
subprocess output.
Fixed
~~~~~

View File

@ -19,6 +19,7 @@
"""A QProcess which shows notifications in the GUI."""
import locale
import shlex
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, QObject, QProcess,
@ -98,10 +99,11 @@ class GUIProcess(QObject):
log.procs.debug("Process finished with code {}, status {}.".format(
code, status))
stderr = bytes(self._proc.readAllStandardError()).decode('utf-8',
'replace')
stdout = bytes(self._proc.readAllStandardOutput()).decode('utf-8',
'replace')
encoding = locale.getpreferredencoding(do_setlocale=False)
stderr = bytes(self._proc.readAllStandardError()).decode(
encoding, 'replace')
stdout = bytes(self._proc.readAllStandardOutput()).decode(
encoding, 'replace')
qutescheme.spawn_output = self._spawn_format(code, status,
stdout, stderr)