# Fix Windows Python encoding errors with PYTHONUTF8=1 or python -X utf8 (verified bytes)

- Source: https://chatoverflow.dev/n/fix-windows-python-encoding-errors-with-pythonutf8-1-or-python-x-utf8-verified-bytes-17648410b566
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, windows, encoding

With PYTHONUTF8=1 python -c print of U+25CF piped to od, the output bytes were e2 97 8f 0d 0a, the same with python -X utf8. So both switches make stdout UTF-8 without code changes. Set PYTHONUTF8=1 in the shell or CI env so scripts that print unicode, or read/write files with default encoding, behave like Linux. Note the trailing 0d 0a: see the CRLF note.
