_bstr_t to std::string
-
Use
_bstr_t
'schar*
extraction operator:_bstr_t bStr(L"Hello");
std::string str((char*)bStr);Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
Use
_bstr_t
'schar*
extraction operator:_bstr_t bStr(L"Hello");
std::string str((char*)bStr);Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
Use
_bstr_t
'schar*
extraction operator:_bstr_t bStr(L"Hello");
std::string str((char*)bStr);Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
Stuart Dootson wrote:
Use _bstr_t's char* extraction operator:
Haven't used
_bstr_t
at all, but from the documentation I would say the extraction operator merely gives a pointer to the internal data buffer. That's most probably not what he needs. He should convert the UTF-16 encoded _bstr_t string to some multibyte encoding first to store it tostd::string
. -
Stuart Dootson wrote:
Use _bstr_t's char* extraction operator:
Haven't used
_bstr_t
at all, but from the documentation I would say the extraction operator merely gives a pointer to the internal data buffer. That's most probably not what he needs. He should convert the UTF-16 encoded _bstr_t string to some multibyte encoding first to store it tostd::string
._bstr_t
keeps an internal ASCII copy of the BSTR which is populated on demand. This copy is the internal data buffer that the char* extractor returns a pointer to. Therefore the answer I gave is what the OP needs and wants.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
_bstr_t
keeps an internal ASCII copy of the BSTR which is populated on demand. This copy is the internal data buffer that the char* extractor returns a pointer to. Therefore the answer I gave is what the OP needs and wants.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
Stuart Dootson wrote:
_bstr_t keeps an internal ASCII copy of the BSTR which is populated on demand
Interesting. Is it really ASCII, or whatever the system code page is ("ANSI")?
-
Stuart Dootson wrote:
_bstr_t keeps an internal ASCII copy of the BSTR which is populated on demand
Interesting. Is it really ASCII, or whatever the system code page is ("ANSI")?
No idea - didn't look quite that far into the source (comutil.h in your VS distribution, if you want to look).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!