Problems handling special characters in Python 3
Python 2
What we get from the LDAP:
sn = 'Budzy\xc5\x84ski'
What we pass to the database to be saved:
>>> unicode(sn, 'utf-8')
u'Budzy\u0144ski'
The contents saved in the MySQL database (table uses UTF-8 encoding):
Budzyński
Python 3
What we get from the LDAP:
sn = b'Budzy\xc5\x84ski'
What we pass to the database to be saved:
>>> sn.decode('utf-8')
'Budzyński'
The contents saved in the MySQL database (table uses UTF-8 encoding):
Budzy?ski