X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6310bbc5a3bce1033c0e579341e115be9df6fe9..e93523680ba3c83cdae75b511214c82f28a2d853:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index 7b9f77b28b..87e5613472 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -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; @@ -1000,7 +999,7 @@ wxString wxString::FromAscii(const char *ascii, size_t len) wxString wxString::FromAscii(const char *ascii) { - return FromAscii(ascii, strlen(ascii)); + return FromAscii(ascii, wxStrlen(ascii)); } wxString wxString::FromAscii(const char ascii)