From 710f83dcf729e3cacd3b47b6a9ba8118765c69f8 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 10 Jan 2013 13:09:33 +0900 Subject: [PATCH] Fix to compile with multibyte characters If a source file contains multibyte characters (Japanese characters), Check Syntax or Display JavaScript fails with UnicodeEncodeError on Windows. Adding encode/decode with utf-8 works without errors. I've tested this on Windows and OS X. --- CoffeeScript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CoffeeScript.py b/CoffeeScript.py index 7cb5429..40316c0 100755 --- a/CoffeeScript.py +++ b/CoffeeScript.py @@ -11,7 +11,7 @@ def run(cmd, args = [], source="", cwd = None, env = None): args = [args] if sys.platform == "win32": proc = Popen([cmd]+args, env=env, cwd=cwd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True) - stat = proc.communicate(input=source) + stat = proc.communicate(input=source.encode('utf-8')) else: if env is None: env = {"PATH": settings.get('binDir', '/usr/local/bin')} @@ -22,7 +22,7 @@ def run(cmd, args = [], source="", cwd = None, env = None): proc = Popen(command, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE) stat = proc.communicate() okay = proc.returncode == 0 - return {"okay": okay, "out": stat[0], "err": stat[1]} + return {"okay": okay, "out": stat[0].decode('utf-8'), "err": stat[1]} def brew(args, source): if sys.platform == "win32":