Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MBCS to UTF-8 C++

Tags:

c++

unicode

utf-8

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!

like image 773
user131091 Avatar asked Jan 23 '23 11:01

user131091


1 Answers

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.

like image 173
avakar Avatar answered Jan 30 '23 05:01

avakar