title is self explanatory how do i convert it to a std::string?
all this LP stuff makes my brain hurt...
twek
0
Newbie Poster
Recommended Answers
Jump to Posttitle is self explanatory how do i convert it to a std::string?
all this LP stuff makes my brain hurt...try static_cast<std::string>(the_LPWSTR_var);
or if it doesn't work
reinterpret_cast<std::string>(the_LPWSTR_var);
Jump to PostIf your program is being compiled for UNICODE and the string is non-English, then more than likely it can not be converted. If English, then there are conversion functions.
Jump to Postbool cvtLPW2stdstring(std::string& s, const LPWSTR pw, UINT codepage = CP_ACP) { bool res = false; char* p = 0; int bsz; bsz = WideCharToMultiByte(codepage, 0, pw,-1, 0,0, 0,0); if (bsz > 0) { p = new char[bsz]; int rc = WideCharToMultiByte(codepage, 0, pw,-1, p,bsz, 0,0); if (rc …
All 11 Replies
minas1
1
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ArkM
1,090
Postaholic
twek
0
Newbie Poster
ArkM
1,090
Postaholic
twek
0
Newbie Poster
ArkM
1,090
Postaholic
twek
0
Newbie Poster
stiwari
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
easysir
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.