patch for Internationalization support (iconv)

Steffen Ries steffen.ries at
Tue Oct 16 14:05:05 CEST 2001

js9s at writes:

> I have sent to Leonard the patch, but did not get any indication of
> its being received, so here I send the patch again, see if it is
> useful to other people.
> I just worked out the python-ldap so that it will convert the local
> characters to utf8 or vice versa according to the user locale setup.
> This is done because OpenLdap currently only support utf8, one has
> to make the translation mannually getting in or out of openldap.  I
> tested on zh_CN.GB2312 (simplified Chinese), and it worked.  By no
> means it is a complete test, but it is a good start, and it worked
> for me.  The patch was generated against the CVS tree check out
> yesterday, so it is pretty recent.

I would be careful with this patch.

It looks to me that you are converting *every* ldap attribute from the
current locale encoding to UTF-8 (and vice versa). This takes care of
the most common attributes, but it affects binary attributes as well,
which it shouldn't.

IMHO a better approach would be to allow Python Unicode strings as
well as regular strings for writing attributes, then encode unicode
strings to UTF-8.

For reading from LDAP, I'm not sure what the best approach would
be. E.g. if the attribute type syntax is "Directory String", create a
unicode string, otherwise create a literal string. But how do you know
the attribute syntax? Maybe it is best to leave the attributes as they
are and leave the encoding to the user...

just my 0.02$

steffen.ries at	<> Gravity is a myth -- the Earth sucks!

More information about the python-ldap mailing list