Python 2.7 still? Unicode and conversions...

home | blog | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts


- Careful Chrome users, this search box might be "Not secure"



Stop using str()
If you are and get:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6:
ordinal not in range(128)

Instead...
More here https://docs.python.org/2.7/howto/unicode.html#the-unicode-type
Short version for the impatient (and in case that link goes away:
- Set your encoding to closer to ascii if possible like:
closertoascii = yourunicodestring.encode('utf-8')
- But it is best to use Unicode across the board as some bits have no replacement..



[æ]