Results 1 to 6 of 6

Thread: stl::string to LPCWSTR

Hybrid View

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    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.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: stl::string to LPCWSTR

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

  4. #4

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: stl::string to LPCWSTR

    http://www.vbforums.com/showthread.p...hlight=unicode

    That was a thread that you started, by the way.
    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.

  6. #6

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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
  •  



Click Here to Expand Forum to Full Width