Skip to content

Commit cbe0196

Browse files
Fixes chinese chars output in Windows with python 2.7
1 parent 41972c6 commit cbe0196

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/robotide/contrib/testrunner/testrunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def _write_argfile(argfile, args):
295295
f = codecs.open(argfile, "wb")
296296
for item in args:
297297
if is_unicode(item):
298-
enc_arg = item.encode(encoding.OUTPUT_ENCODING)
298+
enc_arg = item.encode(encoding.CONSOLE_ENCODING) # DEBUG .OUTPUT_ENCODING)
299299
else:
300300
enc_arg = item
301301
f.write(enc_arg+"\n")

src/robotide/contrib/testrunner/testrunnerplugin.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,9 @@ def _format_command(self, argv):
488488
"""
489489
result = []
490490
for arg in argv:
491-
# if PY2 and is_unicode(arg):
492-
# arg = arg.encode(encoding.OUTPUT_ENCODING) # DEBUG "utf-8")
491+
if PY2 and is_unicode(arg):
492+
arg = arg.encode(encoding.CONSOLE_ENCODING) # DEBUG "utf-8")
493+
# print("DEBUG: PY2 unicode args %s" % arg)
493494
if "'" in arg or " " in arg or "&" in arg:
494495
# for windows, if there are spaces we need to use
495496
# double quotes. Single quotes cause problems
@@ -521,14 +522,20 @@ def _AppendText(self, textctrl, string, source="stdout"):
521522
try:
522523
if PY2:
523524
# textctrl.AppendText(string.encode(encoding.OUTPUT_ENCODING)) # DEBUG encoding.CONSOLE_ENCODING)) # DEBUG 'utf-8'))
524-
textctrl.AppendText(string.encode('utf-8')) # encoding.SYSTEM_ENCODING))
525+
textctrl.AppendText(string.encode(encoding.SYSTEM_ENCODING)) # encoding.SYSTEM_ENCODING)) 'utf-8'
525526
else:
526527
textctrl.AppendText(str(string)) # DEBUG
527528
except UnicodeDecodeError as e:
528529
# I'm not sure why I sometimes get this, and I don't know what I
529530
# can do other than to ignore it.
530531
textctrl.AppendTextRaw(bytes(string)) # DEBUG .encode('utf-8'))
531-
# print("DEBUG UnicodeDecodeError appendtext string=%s\n" % string)
532+
# print(r"DEBUG UnicodeDecodeError appendtext string=%s\n" % string)
533+
pass
534+
except UnicodeEncodeError as e:
535+
# I'm not sure why I sometimes get this, and I don't know what I
536+
# can do other than to ignore it.
537+
textctrl.AppendText(string.encode('utf-8')) # DEBUG .encode('utf-8'))
538+
# print(r"DEBUG UnicodeDecodeError appendtext string=%s\n" % string)
532539
pass
533540
# raise # DEBUG
534541

0 commit comments

Comments
 (0)