C++ LPCWSTR conersion problem

This topic is 3119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

- Edited by CaymenIslands

Share on other sites
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 on other sites
- Edited by CaymenIslands

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 on other sites
Quote:
 Original post by enigmatixI 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.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633360
• Total Posts
3011523
• Who's Online (See full list)

There are no registered users currently online

×