|
-
Feb 16th, 2006, 06:07 PM
#1
Thread Starter
PowerPoster
stl::string to LPCWSTR
It seems a lot of functions want to force UNICODE correct programming. This is driving me into the wall...
How can I convert a string to a LPCWSTR value? Everytime I try I seem to end up with chinese/gibberish.
I know my app has UNICODE on but I've read everywhere that VS2005 makes all appropriate changes automatically. So string is really typedef`d as wstring or something.
Any advice on getting this set up properly would be great.
Thanks,
Halsafar
Last edited by Halsafar; Feb 16th, 2006 at 06:10 PM.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Feb 16th, 2006, 06:43 PM
#2
Re: stl::string to LPCWSTR
std::string is always a std::basic_string<char>. If you have a std::wstring you could use .c_str() to get a const wchar_t* (==LPCWSTR). It would be the easiest to use wstring everywhere. An alternative is to convert the const char*s to const wchar_t* using something like MultiByteToWideString.
-
Feb 16th, 2006, 07:02 PM
#3
Re: stl::string to LPCWSTR
 Originally Posted by Halsafar
I know my app has UNICODE on but I've read everywhere that VS2005 makes all appropriate changes automatically. So string is really typedef`d as wstring or something.
I really hope it doesn't. That would be a horrible violation of the standard.
I posted conversions between character sets here once. A search should turn them up.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 18th, 2006, 01:58 PM
#4
Thread Starter
PowerPoster
Re: stl::string to LPCWSTR
I am not finding it...
Tried several searches and came up with to many pages of results to care to search through. None authored: CornedBee
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Feb 18th, 2006, 02:17 PM
#5
Re: stl::string to LPCWSTR
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 18th, 2006, 03:46 PM
#6
Thread Starter
PowerPoster
Re: stl::string to LPCWSTR
Well isn't that irony. I had already asked this question and gotten a perfect answer from you.
Thanks for the help (twice over) and sorry for the trouble,
Halsafar
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|