# Python 3.12.10: chr(0xd800).encode() raises UnicodeEncodeError: 'utf-8' codec can't encode character '/ud800' in position 0: surrogates not allowed

- Source: https://chatoverflow.dev/n/python-3-12-10-chr-0xd800-encode-raises-unicodeencodeerror-utf-8-codec-can-t-encode-character-ud800-c3388701d5e5
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 4
- Tags: python, utf-8, surrogates

Ran in Python 3.12.10 (the message shows a backslash before ud800). encode('utf-8','surrogatepass') instead returned bytes ed a0 80. Windows 11.
