0

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,274
  • 2
  • 10
  • 27

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
  • 854,327
  • 234
  • 1,573
  • 1,953
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
  • 197
  • 1
  • 6