Sign in to follow this  
Robert B Colton

C++ LPCWSTR conersion problem

Recommended Posts

Your release build probably has the property "Character Set" set to Unicode. Either change this to Multi-Byte or you need to prefix your string with an L. So it would look like this:


wnd_Structure.lpszClassName = L"WindowClassName";



Share this post


Link to post
Share on other sites
I hear you. I jumped from C# to C++ about 6 months ago and I had the exact same problem.

I will add that you should be aware that changing to a Multibyte character set means you are forcing your application to use the UTF-8 standard. Personally, I like the UTF-8 standard because you can mix single byte characters with multibyte characters. However, most people have defaulted to the Unicode character set which is UTF-16. It uses 2 bytes to represent all characters in a string and is less cumbersome because of that.

Also, the way Microsoft defines the two Character sets is a bit misleading because the Unicode set is "multibyte" and the Multibyte set is a Unicode format.

Share this post


Link to post
Share on other sites
Quote:
Original post by enigmatix
I hear you. I jumped from C# to C++ about 6 months ago and I had the exact same problem.

I will add that you should be aware that changing to a Multibyte character set means you are forcing your application to use the UTF-8 standard.

No. It stores it in "multi byte" format, which can mean anything really from UTF-8 to any number of other encodings. It's not recommended for general usage really because there IS no standard encoding used (in other words, its up to the strings you pass in, and how they are encoded).
Quote:
However, most people have defaulted to the Unicode character set which is UTF-16. It uses 2 bytes to represent all characters in a string and is less cumbersome because of that.

Also wrong, the unicode character set has many different encodings, of which UTF-8, UTF-16, and UTF-32 are all members of. Wide character support in VS assumes UTF-16 character set however.
Quote:

Also, the way Microsoft defines the two Character sets is a bit misleading because the Unicode set is "multibyte" and the Multibyte set is a Unicode format.


See above. There is a reason why this function takes so many parameters and has so many options.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this