MCPcopy Create free account
hub / github.com/FastLED/FastLED / _setup_utf8_output

Function _setup_utf8_output

ci/tests/test_platformio_url_resolution.py:28–47  ·  view source on GitHub ↗

Setup UTF-8 output for Windows compatibility when running directly.

()

Source from the content-addressed store, hash-verified

26
27# Ensure UTF-8 output on Windows and other platforms (only when running directly)
28def _setup_utf8_output():
29 """Setup UTF-8 output for Windows compatibility when running directly."""
30 if sys.platform.startswith("win") and not hasattr(sys.stdout, "_pytest_wrapped"):
31 # Only apply UTF-8 wrapping when not running under pytest
32 try:
33 # Force UTF-8 encoding on Windows to prevent emoji crashes
34 import codecs
35
36 if not isinstance(sys.stdout, codecs.StreamWriter):
37 sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) # type: ignore
38 if not isinstance(sys.stderr, codecs.StreamWriter):
39 sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach()) # type: ignore
40
41 # Set console code page to UTF-8 if possible
42 os.system("chcp 65001 > nul 2>&1")
43 except KeyboardInterrupt as ki:
44 handle_keyboard_interrupt(ki)
45 raise
46 except:
47 pass # Ignore if we can't set up UTF-8 output
48
49
50from ci.compiler.platformio_cache import PlatformIOCache

Callers 1

mainFunction · 0.85

Calls 1

Tested by

no test coverage detected