CKTIS / Python
chr()
Creates a string containing the Unicode character for an integer code point.
Version: Python 3.14; repository image, production runtime not attested
Syntax
chr(i, /)Creates a string containing the Unicode character for an integer code point.
A code point above the Unicode maximum raises ValueError rather than wrapping into range.
Maps an integer code point in 0 through 0x10ffff inclusive to a one-character string. Hex 03A9 denotes capital omega. The next integer after the largest allowed value, 0x110000, raises ValueError. A code point can be a surrogate even when it cannot be encoded as plain UTF-8.
assert chr(0x03A9) == "Ω" and ord(chr(0x10ffff)) == 0x10ffff
assert len(chr(0xd800)) == 1
Examples
print(chr(0x03A9))
try:
chr(0x110000)
except ValueError as error:
print(type(error).__name__)
Result
Ω ValueError
Maps an integer code point in 0 through 0x10ffff inclusive to a one-character string. Hex 03A9 denotes capital omega. The next integer after the largest allowed value, 0x110000, raises ValueError. A code point can be a surrogate even when it cannot be encoded as plain UTF-8.