use BSTR length to also deal with NULs inside BSTRs correctly in Unicode build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,19 +80,21 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
|
|||||||
if ( !bStr )
|
if ( !bStr )
|
||||||
return wxString();
|
return wxString();
|
||||||
|
|
||||||
|
const int len = SysStringLen(bStr);
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxString str(bStr);
|
wxString str(bStr, len);
|
||||||
#else
|
#else
|
||||||
wxString str;
|
wxString str;
|
||||||
const int len = SysStringLen(bStr) + 1;
|
|
||||||
if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */,
|
if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */,
|
||||||
bStr, len,
|
bStr, len + 1 /* include last NUL */,
|
||||||
wxStringBuffer(str, len), len,
|
wxStringBuffer(str, len), len,
|
||||||
NULL, NULL /* no default char */) )
|
NULL, NULL /* no default char */) )
|
||||||
{
|
{
|
||||||
str.clear();
|
str.clear();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user