Converting to wide character strings

A

Alamelu

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

Giovanni Dicanio

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
 
D

David Wilkinson

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.
 
F

fineman

You can use MultiByteToWideChar API.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top