fixed FromAscii() changes to correctly handle embedded NULs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47011 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2007-06-28 19:07:00 +00:00
parent 75ce4cb180
commit 602a857b25

View File

@ -980,19 +980,18 @@ wxString wxString::FromAscii(const char *ascii, size_t len)
wxString res;
wxImplStringBuffer buf(res, len);
wxStringCharType *dest = buf;
for ( ;; )
{
unsigned char c = (unsigned char)*ascii++;
wxASSERT_MSG( c < 0x80,
_T("Non-ASCII value passed to FromAscii().") );
wxImplStringBuffer buf(res, len);
wxStringCharType *dest = buf;
*dest++ = (wchar_t)c;
for ( ; len > 0; --len )
{
unsigned char c = (unsigned char)*ascii++;
wxASSERT_MSG( c < 0x80,
_T("Non-ASCII value passed to FromAscii().") );
if ( c == '\0' )
break;
*dest++ = (wchar_t)c;
}
}
return res;