1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unicode to UTF8 and UTF16 ?

Discussion in 'C' started by ceus, Jun 18, 2009.

  1. ceus

    ceus New Member

    Joined:
    Oct 16, 2006
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,
    Can anyone tell me how can i convert a unicode string to UTF8 and UTF16 ? say, i have like this ?

    WCHAR unicodebuf[] = L"Hello how are u ???喂";
    // The last charecter in the above string is (hello) in CHINEESE

    WCHAR utfbuf8[100] = L"";
    WCHAR utfbuf16[100] = L"";

    Now i want utfbuf8 and utfbuf16 to contain the encoded value of unicodebuf in utf8 and utf16 respectively... how can i do this ?
    Thanks..
     
  2. Aesop

    Aesop New Member

    Joined:
    Jun 19, 2009
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    WideCharToMultiByte can convert a WCHAR string to UTF-8.

    It may be that WCHAR is the same as UTF-16, but someone will have to confirm that as I haven't done much with Unicode.
     

Share This Page