Internationalization patch, i18n, iconv, ...
js9s at netscape.net
js9s at netscape.net
Tue Oct 16 19:41:00 CEST 2001
The iconv is part of glibc 2.2.2 and above, so iconv.h should be in any recent LINUX system if the C developement environment is configured. If older than glic 2.2.2, you might have to install the iconvlib seperately.
I did try to use PyString_(De/En)code, but it is not very well suited to openldap type of applications, especially if dn has mixed ascii and utf8 encodings. But I will be happy if someone can prove I am wrong.
Thanks.
J.
David Leonard <david.leonard at itee.uq.edu.au> wrote:
>
>On Sat, 13 Oct 2001, js9s at netscape.net 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.
>
>hi
>
>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 */
> );
>
>
>d
>
>--
>David Leonard David.Leonard at itee.uq.edu.au
>Dept of Inf. Tech. and Elec. Engg _ Ph:+61 404 844 850
>The University of Queensland |+| http://www.itee.uq.edu.au/~leonard/
>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