I have a simple code:
# -*- coding: utf-8 -*-
text = "12É45678"
print(len(text))
See the Upper E with accent
Then when I run from python 2, the result is 9 when I run from python 3, the result is 8
How to obtain 8 in python 2 (native)
I have a simple code:
# -*- coding: utf-8 -*-
text = "12É45678"
print(len(text))
See the Upper E with accent
Then when I run from python 2, the result is 9 when I run from python 3, the result is 8
How to obtain 8 in python 2 (native)
In Python 2,
stris a naive sequence of bytes (what we callbytesin Python 3). To interpret arbitrary bytes as unicode codepoints, you need to decode them into aunicodeobject:In Python 2, this prints
See also the Unicode HOWTO from the Python 2 documentation.