conversion of String to LPWSTR

i want to convert String to LPWSTR.

how can i do that, i tried:

LPWSTR test = (wchar_t*)ext.toStdWString().c_str();

where 'ext' is string. but it returns garbage value in 'test'

please help



Answer this question

conversion of String to LPWSTR

  • James Liddell

    Never heard and never read about toStdWString

  • Olivier Georg

    Linux world I believe. Qt, MySql.



  • Snadge

    What is toStdWString
    Is ext realy a std::string

    You can usethe ATL conversion fucntions:

    USES_CONVERSION;
    LPWSTR test = A2W(ext.c_str());

    or if you just need the pointer fur a short time you can use CA2W!



  • Luis Forero

    Not sure what toStdWString() does but it sounds like it converts to LPWSTR. You then call c_str() which converts it back to LPSTR. And added the wchar_t cast to keep the compiler from telling you you're doing something wrong.

    Try it like this:
    LPWSTR test = ext.toStdWString();



  • conversion of String to LPWSTR