Internationalization patch, i18n, iconv, ...

David Leonard david.leonard at
Tue Oct 16 13:34:03 CEST 2001

On Sat, 13 Oct 2001, js9s at typed thusly:
> I just worked out the python-ldap so that it will convert the
> local charactors to utf8 or vice versa according to the user locale
> setup.   This is done because OpenLdap currently only support utf8,
> so  one has to make the  translation.   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.
> Here is the patch in the attachment.


sorry i have been unable to respond to you - i had marked your
message important but have been busy of late. :(

i'm glad you send it to the list, because it will stand a better chance
of being reviewed there.. a better chance than just sitting in my mailbox.

here are my comments from a quick perusal of the diff

... the diff is reversed. (took me a moment to figure out what was
going on there!.. the order is 'diff <old> <new>')

... you're relying on an iconv.h header file, which isn't on every
system. (especially mine)

.. I think instead to use PyString_Decode() and PyString_Encode()..
that way you get python unicode string objects.

i'm not an expert on these things, but here is a cut and paste from
a python header file:

/* Create a string object by decoding the encoded string s of the
   given size. */

extern DL_IMPORT(PyObject*) PyString_Decode(
    const char *s,              /* encoded string */
    int size,                   /* size of buffer */
    const char *encoding,       /* encoding */
    const char *errors          /* error handling */

/* Encodes a char buffer of the given size and returns a
   Python string object. */

extern DL_IMPORT(PyObject*) PyString_Encode(
    const char *s,              /* string char buffer */
    int size,                   /* number of chars to encode */
    const char *encoding,       /* encoding */
    const char *errors          /* error handling */


David Leonard                           David.Leonard at
Dept of Inf. Tech. and Elec. Engg   _   Ph:+61 404 844 850
The University of Queensland       |+|
QLD 4072  AUSTRALIA               ~` '~ B73CD65FBEF4C089B79A8EBADF1A932F13EA0FC8

Make sure that you have enough free memory in your temp directory.
	- Sun StarOffice README

More information about the python-ldap mailing list