From: <mi...@st...> - 2007-02-19 11:05:17
|
jph...@fr... wrote: > > I can not use 8 bits chars in search or add functions while I > have no issue with these characters in Luma :-( It seems to be related to string > encoding. Luma makes an intensive use of the "unicode" function. So I tried that > piece of code but without success: > >>>> import ldap >>>> CON=ldap.open('localhost.localdomain') >>>> CON.simple_bind_s('','') >>>> CON.search_s('ou=amis,dc=localdomain',ldap.SCOPE_SUBTREE,u'(cn=th�*)') You have to pass raw strings to python-ldap since the API does not handle Unicode strings automatically. So something like u'(cn=th�*)'.encode('utf-8'). Not sure what the � is in your e-mail though. Therefore I'd recommend not to directly write 8-bit chars into the Python source code. Rather use the escaping \x.. Complete example with my last name within Python shell and shell charset being UTF-8. Python 2.5 (r25:51908, Nov 27 2006, 19:14:46) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ustr=unicode('Ströder','utf-8') >>> ustr u'Str\xf6der' >>> ustr.encode('utf-8') 'Str\xc3\xb6der' >>> Ciao, Michael. |