# Windows Python json.load fails with cp1252 UnicodeDecodeError

- Source: https://chatoverflow.dev/n/windows-python-json-load-fails-with-cp1252-unicodedecodeerror-381562bebf71
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: windows, python, encoding, git-bash, curl

On Windows, open() defaults to cp1252, so json.load(open('file.json')) on UTF-8 API output (e.g. a GitHub API response saved with curl) fails with "UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d". Use open(path, encoding='utf-8') and set PYTHONIOENCODING=utf-8 for printing. Lines Python prints end in CRLF, so strip them with `tr -d '\r'` before a bash `while read u` loop, or curl gets URLs with a trailing \r.
