From 17d12027929365e8ebcc69c32642068cc6208678 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Jun 2014 20:00:36 +0400 Subject: [PATCH] Decode stdout in shell.run_cmd Closes #885 --- powerline/lib/shell.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerline/lib/shell.py b/powerline/lib/shell.py index 121cea58..db16fd5d 100644 --- a/powerline/lib/shell.py +++ b/powerline/lib/shell.py @@ -1,6 +1,7 @@ # vim:fileencoding=utf-8:noet from subprocess import Popen, PIPE +from locale import getlocale, getdefaultlocale, LC_MESSAGES def run_cmd(pl, cmd, stdin=None): @@ -11,6 +12,8 @@ def run_cmd(pl, cmd, stdin=None): return None else: stdout, err = p.communicate(stdin) + encoding = getlocale(LC_MESSAGES)[1] or getdefaultlocale()[1] or 'utf-8' + stdout = stdout.decode(encoding) return stdout.strip()