return SubstrBufFromMB("", 0);
// and then to UTF-8:
- SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvUTF8()));
+ SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvStrictUTF8()));
// widechar -> UTF-8 conversion isn't supposed to ever fail:
wxASSERT_MSG( buf.data, _T("conversion to UTF-8 failed") );
const wxWCharBuffer wxString::wc_str() const
{
- return wxMBConvUTF8().cMB2WC(m_impl.c_str(),
- m_impl.length() + 1 /* size, not length */,
- NULL);
+ return wxMBConvStrictUTF8().cMB2WC
+ (
+ m_impl.c_str(),
+ m_impl.length() + 1, // size, not length
+ NULL
+ );
}
const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
// FIXME-UTF8: use wc_str() here once we have buffers with length
size_t wcLen;
- wxWCharBuffer wcBuf(
- wxMBConvUTF8().cMB2WC(m_impl.c_str(),
- m_impl.length() + 1 /* size, not length */,
- &wcLen));
+ wxWCharBuffer wcBuf(wxMBConvStrictUTF8().cMB2WC
+ (
+ m_impl.c_str(),
+ m_impl.length() + 1, // size
+ &wcLen
+ ));
if ( !wcLen )
return wxCharBuffer("");
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;
wxString wxString::FromAscii(const char *ascii)
{
- return FromAscii(ascii, strlen(ascii));
+ return FromAscii(ascii, wxStrlen(ascii));
}
wxString wxString::FromAscii(const char ascii)