C win32 api unicode to ascii

6.2k Views Asked by At

Possible Duplicate:
How do you convert LPCWSTR to const char *?

I have a function that gets a LPCWSTR string for win32 api usage. Now I have a function that sends data in ASCII to the IRC server. So now I need to convert it to ASCII, I haven't found any solutions, I only found ways to convert ASCII to UNICODE.

1

There are 1 best solutions below

1
On

WideCharToMultiByte converts from UNICODE to MBCS. If your original wide char string consisted only of characters which could be represented in ASCII, then this will result in a ASCII string. You can also use wcstombs which internally calls WideCharToMultiByte.

Either way, you will get a LPSTR or char * (which are the same).