user2081738
user2081738

Reputation:

Python: Printing unicode characters beyond FFFF

On Python 3 printing unicode characters can be printed like this:

print('\uFFFF')

But how can I print higher unicode characters like 001FFFFF? print('\u001FFFFF') will just print 001F as unicode character and then 4 times F. Trying to use print('\u001F\uFFFF') will result in 2 unicode characters instead of the wanted one. Is it possible to print somehow the unicode character 001FFFFF in Python 3?

Upvotes: 4

Views: 857

Answers (2)

YaOzI
YaOzI

Reputation: 17548

There is another way in Python 3, using the built-in function chr(i), which

Return the string representing a character whose Unicode code point is the integer i.

and

The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in base 16).

so there are no limitation for the hex digit value.

print(chr(97))
print(chr(0xFFFF))
print(chr(0x10080))

Upvotes: 1

Mark Ransom
Mark Ransom

Reputation: 308520

Use an upper-case U.

print('\U001FFFFF')

Upvotes: 6

Related Questions