How can I convert a wchar_t * to char *? My code is something like that but it just get the first character:
wchar_t * filename= L"C:\\test";
char* c = (char*)filename;
Welcome to the wonderful world of Unicode and the non ASCII world (most of the
real world actually). A wchar_t is a 16 bit codepoint. Most likely codepoints are
stored in little endian order on your machine because you can read the first
'character' which happens to be the ASCII codepoint for an upper case C while
the hi byte equals zero.
Basically you can't just chop off the high byte from a wchar_t to get your char.
You have to decide how you want to encode those 16 bit codepoints to 8 bit
encoded bytes. I suggest UTF-8 for this.
Read all about it at the
Unicode site.
best of luck and
kind regards,
Jos