I get argv as wchar_t** (see below), because I need to work with unicode, but I need to convert it to char **. How can I do that?
int wmain(int argc, wchar_t** argv)
{
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is more than one way to do this. Depending on your environment and available compiler/standard library/other libraries, you have at least three choices:
Do you really need to do the conversion?
You should realise that often (especially on Windows) the conversion from wchar_t string to char string is a lossy conversion. The character set used by system for char strings is often not UTF-8. E.g. if you convert a file name with national characters or in some Asian language to char string you are most likely going to get something that will not be really usable to access the original file.