added wxString::FromAscii(char*,size_t) for consistency with FromUTF8()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-06-28 12:36:54 +00:00
parent edc0987174
commit e6310bbc5a
3 changed files with 26 additions and 20 deletions

View File

@@ -973,35 +973,36 @@ int wxString::CmpNoCase(const wxString& s) const
#endif
#endif
wxString wxString::FromAscii(const char *ascii)
wxString wxString::FromAscii(const char *ascii, size_t len)
{
if (!ascii)
if (!ascii || len == 0)
return wxEmptyString;
size_t len = strlen(ascii);
wxString res;
if ( len )
wxImplStringBuffer buf(res, len);
wxStringCharType *dest = buf;
for ( ;; )
{
wxImplStringBuffer buf(res, len);
wxStringCharType *dest = buf;
unsigned char c = (unsigned char)*ascii++;
wxASSERT_MSG( c < 0x80,
_T("Non-ASCII value passed to FromAscii().") );
for ( ;; )
{
unsigned char c = (unsigned char)*ascii++;
wxASSERT_MSG( c < 0x80,
_T("Non-ASCII value passed to FromAscii().") );
*dest++ = (wchar_t)c;
*dest++ = (wchar_t)c;
if ( c == '\0' )
break;
}
if ( c == '\0' )
break;
}
return res;
}
wxString wxString::FromAscii(const char *ascii)
{
return FromAscii(ascii, strlen(ascii));
}
wxString wxString::FromAscii(const char ascii)
{
// What do we do with '\0' ?