From 27cb4fc6652c6bf7c18438ba45a9ba7e435468ef Mon Sep 17 00:00:00 2001
From: kice <wslikerqs@gmail.com>
Date: Sun, 25 Nov 2018 17:39:26 -0500
Subject: [PATCH] Fix str decoding error on non-English Windows (#2158)

---
 python/tvm/_ffi/base.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/python/tvm/_ffi/base.py b/python/tvm/_ffi/base.py
index 0a91c4112..2579f22e4 100644
--- a/python/tvm/_ffi/base.py
+++ b/python/tvm/_ffi/base.py
@@ -18,7 +18,11 @@ if sys.version_info[0] == 3:
     numeric_types = integer_types + (float, np.float32)
     # this function is needed for python3
     # to convert ctypes.char_p .value back to python str
-    py_str = lambda x: x.decode('utf-8')
+    if sys.platform == "win32":
+        encoding = 'cp' + str(ctypes.cdll.kernel32.GetACP())
+        py_str = lambda x: x.decode(encoding)
+    else:
+        py_str = lambda x: x.decode('utf-8')
 else:
     string_types = (basestring,)
     integer_types = (int, long, np.int32)
-- 
GitLab