user131091
user131091

Reputation: 207

MBCS to UTF-8 C++

I'm working on a project in VS2008 that I'm compiling in MBCS but I need to work with some UTF-8 strings to interact with some web services. I wrote a function that works perfectly with Unicode but not MBCS. Is there any way I can convert a MBCS string to UTF-8 or to Unicode?

Thanks!

Upvotes: 4

Views: 2361

Answers (1)

avakar
avakar

Reputation: 32635

Convert the MBCS string to Unicode using MultiByteToWideChar and then to UTF-8 with WideCharToMultiByte. Pass CP_ACP to the first call and CP_UTF8 to the second.

Upvotes: 9

Related Questions