Skip to content

Commit 40ca69a

Browse files
committed
fix windows UnicodeEncodeError after render completes
1 parent 7740543 commit 40ca69a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

plain2code.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ def run_render():
268268

269269

270270
def main(): # noqa: C901
271+
# On Windows, stdout uses cp1252 encoding instead of UTF-8. It cannot print "✓".
272+
# Use UTF-8 to prevent: UnicodeEncodeError
273+
if sys.platform == "win32":
274+
for stream in (sys.stdout, sys.stderr):
275+
try:
276+
stream.reconfigure(encoding="utf-8", errors="replace")
277+
except (AttributeError, OSError):
278+
pass
279+
271280
args = parse_arguments()
272281

273282
# Handle early-exit flags before heavy initialization

0 commit comments

Comments
 (0)