Skip to content Skip to sidebar Skip to footer

Working With Unicode Encoded Strings From Active Directory Via Python-ldap

I already came up with this problem, but after some testing I decided to create a new question with some more specific Infos: I am reading user accounts with python-ldap (and Pytho

Solution 1:

First, know that printing to a Windows console is often the step that garbles data, so for your tests, you should print repr(s) to see the precise bytes you have in your string.

You need to find out how the data from AD is encoded. Again, print repr(s) will let you see the content of the data.

UPDATED:

OK, it looks like you're getting strange strings somehow. There might be a way to get them better, but you can adapt in any case, though it isn't pretty:

u.decode('unicode_escape').encode('iso8859-1').decode('utf8')

You might want to look into whether you can get the data in a more natural format.

Post a Comment for "Working With Unicode Encoded Strings From Active Directory Via Python-ldap"