Re: LPCTSTR to std::string
- From: "Jacky Luk" <jl@xxxxxxxxxx>
- Date: Sat, 30 Sep 2006 20:58:10 +0800
doesn't seem to work well in 16-bit characters (foreign characters), the
assignment returns a trash string...
BOOL Cdecom7Doc::OnOpenDocument(LPCTSTR lpszPathName)
{
std::string fileName;
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
fileName = lpszPathName; <<<< trash!!!
// SetFileName(lpszPathName);
m_pFile = new cFile();
m_pFile->OpenfileEx(fileName);
// TODO: Add your specialized creation code here
return TRUE;
}
"Abdo Haji-Ali" <ahali@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:uXYOkoI5GHA.2596@xxxxxxxxxxxxxxxxxxxxxxx
"Jacky Luk" <jl@xxxxxxxxxx> wrote in message
news:uT4bsfI5GHA.2536@xxxxxxxxxxxxxxxxxxxxxxx
HiIn this case it's not a "cast". It's an "assignment" or "copying"...
How to cast a LPCTSTR to std::string?
Do I justThis is the way to do it (it's called assignment)
m_fileName = lpszPathName;
orIf you try this one it would give a compiler error, because you can't
strcpy (m_fileName, lpszPathName);
"cast"
an std:string to char* (only const char*)
orWhat do you mean by useful? Easier? Faster? Funnier :)
there is something more useful?
--
Abdo Haji-Ali
Programmer
In|Framez
.
- Follow-Ups:
- Re: LPCTSTR to std::string
- From: Abdo Haji-Ali
- Re: LPCTSTR to std::string
- References:
- LPCTSTR to std::string
- From: Jacky Luk
- Re: LPCTSTR to std::string
- From: Abdo Haji-Ali
- LPCTSTR to std::string
- Prev by Date: Re: LPCTSTR to std::string
- Next by Date: Re: Debugging: obtaining symbol and line from address using .pdb file
- Previous by thread: Re: LPCTSTR to std::string
- Next by thread: Re: LPCTSTR to std::string
- Index(es):