3 ms·
CPython aren't actually using unicode strings. Instead of having a sequence of codepoints, you will have either UCS2 or UCS4 strings depending on compile time o
by gorset 16y ago
CPython aren't actually using unicode strings. Instead of having a sequence of codepoints, you will have either UCS2 or UCS4 strings depending on compile time options.
For example, freshly installed python3.2 from macports:
>>> len(chr(119074))
2
>>> chr(119074)
'𝄢'
>>> print chr(119074)
𝄢
(Surrogates are so much fun).
Python 2.7.1 compiled with UCS4:
>>> len(unichr(119074))
1
>>> unichr(119074)
u'\U0001d122'
>>> print(chr(119074))
𝄢
Notice the capital U takes 8 instead of 4 hexidecimals.