Converting to wide character strings

  • Thread starter Thread starter Alamelu
  • Start date Start date
A

Alamelu

I am take string input from int main arguments, how to convert those strings
to wide character strings
 
Alamelu said:
I am take string input from int main arguments, how to convert those
strings
to wide character strings

There are several options.

You may want to use the ATL helper conversion classes, like CA2W:

const char * ansiString ...

CA2W wideString( ansiString );

And use wideString wherever a const wchar_t * is required.

Or CStringW class has a constructor to do the conversion:

CStringW wideString( ansiString );

Note that you can use these ATL classes from both pure Win32 C++ projects
and MFC projects.

HTH,
Giovanni
 
Alamelu said:
I am take string input from int main arguments, how to convert those strings
to wide character strings

Alemelu:

In addition to Giovanni's answer, if you use wmain() or _tmain() instead of
main() then the arguments are already presented as wide strings.
 
You can use MultiByteToWideChar API.

get more help, search "Unicode and Character Set Reference" in the MSDN.
 
Back
Top