-1

Does anybody know if there is a specific reason why the chr function throws an error if I enter a number higher than 1114111? EG:

>>> chr(1114111)
'\U0010ffff'
>>> chr(1114112)

Traceback (most recent call last): File "", line 1, in chr(1114112) ValueError: chr() arg not in range(0x110000)

Zhubei Federer
  • 1,247
  • 2
  • 9
  • 26

2 Answers2

1

Yes, there is a specific reason. It's because that's the highest code point in the Unicode code space. From the current standard (12.0), section 1.3 Text handling, under Text elements:

An encoded character is represented by a number from 0 to 10ffff16, called a code point.

paxdiablo
  • 814,905
  • 225
  • 1,535
  • 1,899
0

Numbers need to be in a certain range in order to be valid, so no it won’t accept a number greater than or equal to 0x110000 because that is the smallest positive integer that is not in the unicode code space.

Number File
  • 191
  • 6