You must convert the Chinese string from the native character set encoding to the UTF8 encoding. The iPlanet Directory Server used to ship with a command line utility called Native2Ascii or something like that. Assuming you have your command line environment locale and lang set up correctly, you can use this program to convert your native charset to utf8 (ascii). Many operating systems also provide a program called iconv (or something like that) which does the same thing. LDAP only deals with UTF8 strings.

Finally, ldapsearch will not convert back to the native charset. Since the output contains 8 bit characters, ldapsearch will, by default, assume it is binary data and convert it to base64 for display on the terminal window.

zhangmeng wrote:
hello,
    I just want to know, how to add Chinese string to Openldap using LDAP C
SDK for windows.
    the parameters in the SDK is char *, for example:
        LDAP_API(int) LDAP_CALL ldap_add( LDAP *ld, const char *dn, LDAPMod
**attrs );

    the problem is:
    (1) if i use Chinese in const char *dn, then the entry can be added to
LDAP server,
but when i use ldapsearch to check it, i found the dn is strange, like:
    dn:: Y249suLK1MP7s8YgQiBKZW5zZW4sIGRjPWpldHNlbixkYz1jb20=

    (2) if i use Chinese in LDAPMod **attrs, for example, set cn to a
Chinese string,
then, the SDK always return error in code(i used sun ldap_c_sdk
5.08\examples\add.c for
testing):

if (( rc = ldap_result2error( ld, result, 0 )) == LDAP_SUCCESS ) {
  printf( "Entry added successfully.  I counted to %ld "
   "while waiting.\n", global_counter );
     } else {
  printf( "Error while adding entry: %s\n",
   ldap_err2string( rc ));
     }

    the error string is:
    Error while adding entry: Invalid syntax


so, any suggestion?






_______________________________________________ mozilla-directory mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-directory

Reply via email to