<string> to LPCSTR? Also, character encoding: UNICODE vs ?
Okay this is a two part question the first being a direct programming question and the second being a more vague programming question. Feel free to answer one; both; or none.
-----------------------------------------------------------------------
Question 1: I always have used char * when I need to use strings, however, everyone seems to really like <string> so I am giving it a try. However, when a function needs a LPCSTR passing in a <string> object gives a compile time error and trying to cast won't work, which I can understand.
Code:
LoadLibrary(gameName);
Code:
error C2664: 'LoadLibraryA' : cannot convert parameter 1 from 'std::string' to 'LPCSTR'
Anyway to get the above to work or should I just go back to char*?
-------------------------------------------------------------------------
Second question:
I am a bit confused on this issue of character encoding. I never really looked into it before so I didn't know the difference between ANSI & Unicode. However, I recently decided to do a GOOGLE to learn what these are all about.
By default Microsoft Visual Studio has unicode character encoding set and this caused my code not to compile as I had learned the language:
i.e.
Code:
windowClassEx.lpszClassName = "Main";
Would result in a compile time error of:
Code:
error C2440: '=' : cannot convert from 'const char [4]' to 'LPCWSTR'
I was told that i needed to use the TEXT() to get it to work or a simple setting adjustment of not using Unicode would correct this issue. Of course, not being partial to change I chose to change the character set away from UNICODE. However, I accidentaly stumbled across this site in my attempt to understand character sets:
http://www.csc.calpoly.edu/~bfriesen/software/builds.html
It seems to imply that ANSI was meant for early versions of windows (95/98/ME) while UNICODE will actually perform faster on a newer OS (NT/2000/XP) than an ANSI program. This accurate?
If so, am I hurting my programming practices by not using UNICODE?
Right now I'm not sure what I'm using. I have the Character set option to "Not set", but if I set it to "Use Multi-Byte Character Set" my program will still compile as is. Uh, is Multi-Byte the same as UNICODE cause I would think ANSI is just stored as one byte (256 variations).. no? Err, I'm kinda confused on this.
Should I have it set to UNICODE and be using the TEXT macro? Just wondering cause UNICODE is the default setting in Microsoft Visual Studio 2005 and I'm assuming its that way for a reason. Also, if I choose UNICODE will my program run under (windows 95/98/ME)? What other advantages would UNICODE have? I understand it is designed to handle worldwide languages/characters, but what good would that do for my program?