ldap_get_values: converting UTF8 encoding to ANSI MBCS string on UNIX systems

Discussion in 'C++' started by Tejas, Nov 14, 2007.

  1. Tejas

    Tejas Guest

    Hi,

    I am using ldap_get_values() call to get the user attributes from
    LDAP.

    This call is returning the user attributes in UTF-8 encoding and its a
    PCHAR*. For normal English characters this is working well. When
    Multibyte characters are involved like Japanese, Chinese or Korean, I
    need to convert UTF8 to ANSI encoding to get the correct values.

    On Windows platform I am using MultiByteToWideChar() with the code
    page CP_UTF8 to convert it to wide character string and converting it
    back to ANSI string using the ATL macro W2A() with USES_CONVERSION.

    I need to do the same conversion on UNIX machines. I can think of
    mbstowcs() and wcstombs(). However these two calls don't change the
    encoding.

    Can someone let me know how do I change the encoding from UTF-8 to
    ANSI string on UNIX platforms (or same call which works on both UNIX &
    Windows) ?

    Thanks in advance,
    Ravi Nandibhatla.
     
    Tejas, Nov 14, 2007
    #1
    1. Advertising

  2. Tejas <> wrote:
    <snip>
    > I need to do the same conversion on UNIX machines. I can think of
    > mbstowcs() and wcstombs(). However these two calls don't change the
    > encoding.
    >
    > Can someone let me know how do I change the encoding from UTF-8 to
    > ANSI string on UNIX platforms (or same call which works on both UNIX &
    > Windows) ?


    $ man 3 iconv

    alternatively, http://www.icu-project.org/
     
    William Ahern, Nov 14, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,946
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Edward K. Ream
    Replies:
    5
    Views:
    646
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Oct 23, 2003
  3. Giovanni Bajo
    Replies:
    2
    Views:
    521
    Martin v. Löwis
    Jan 27, 2008
  4. Skip Montanaro

    2to3 on Mac - unknown encoding: mbcs

    Skip Montanaro, Nov 6, 2009, in forum: Python
    Replies:
    0
    Views:
    405
    Skip Montanaro
    Nov 6, 2009
  5. Gabriel Genellina

    Re: 2to3 on Mac - unknown encoding: mbcs

    Gabriel Genellina, Nov 6, 2009, in forum: Python
    Replies:
    0
    Views:
    581
    Gabriel Genellina
    Nov 6, 2009
Loading...

Share This Page