locked
MultiByteToWideChar Conversion Problem RRS feed

  • Question

  • Hi,

    I am facing  a problem in converting data from CP 1252  (WIN 1252) to UNICODE (UTF-8) using MultiByteToWideChar API.

    My Text data consists some of the characters in range 0x80-0xFF. When I use the MultiByteToWideChar for conversion into UTF8, It doesn't

    provides me the valid UTF8 data. Could any one help me in solving this problem. Plesae send me If you have any sample code to do this in VC++.

    Waiting for your valuable reply.

    Thanks & Regards

    Gouse


    Prashant

    Thursday, March 29, 2012 6:40 AM

Answers

  • Hi,
     
    I am facing a problem in converting data from CP 1252 (WIN 1252) to UNICODE (UTF-8) using MultiByteToWideChar API.
    To convert from local code page to UTF-8, you must use MultiByteToWideChar() using CP_ACP, followed by WideCharToMultiByte() using CP_UTF8.
     

    David Wilkinson | Visual C++ MVP
    Thursday, March 29, 2012 2:24 PM

All replies

  • Can you Show your code here. And what is the return value of your MultiByteToWideChar()  function.

    Thanks


    Rupesh Shukla

    Thursday, March 29, 2012 2:05 PM
  • Hi,
     
    I am facing a problem in converting data from CP 1252 (WIN 1252) to UNICODE (UTF-8) using MultiByteToWideChar API.
    To convert from local code page to UTF-8, you must use MultiByteToWideChar() using CP_ACP, followed by WideCharToMultiByte() using CP_UTF8.
     

    David Wilkinson | Visual C++ MVP
    Thursday, March 29, 2012 2:24 PM
  • Prashant Dedaniya wrote:
    >
    >I am facing  a problem in converting data from CP 1252  (WIN 1252)
    >to UNICODE (UTF-8) using MultiByteToWideChar API.
     
    MultiByteToWideChar produces UTF-16, not UTF-8.  UTF-8 is considered by
    Windows to be just another multi-byte character set.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Friday, March 30, 2012 4:02 AM