浏览代码

fix console encoding on windows

Johann 4 年之前
父节点
当前提交
9c1e267cc0
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      resources/scripts/lazpaint/command.py

+ 7 - 0
resources/scripts/lazpaint/command.py

@@ -6,6 +6,13 @@ print("LazPaint script\t")
 if input('') != chr(27) + 'LazPaint': 
   print("Needs to be run from LazPaint.")
   exit()
+  
+import sys
+if sys.platform == "win32":
+  import io
+  sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
+  sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
+  sys.stdin = io.TextIOWrapper(sys.stdin.detach(), encoding = 'utf-8')
 
 def parse_str(text: str):
   if text[:1] == "#":