X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3e8e3c0aa864da4c7e5bfbee200d9f0732cf4c5..395367bcd303ad3b8fbf7d4f523f62d72ec7fa55:/include/wx/string.h?ds=sidebyside diff --git a/include/wx/string.h b/include/wx/string.h index 43bde5e5c1..dac27573fa 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -201,7 +201,7 @@ public: const wchar_t* AsWChar() const; operator const wchar_t*() const { return AsWChar(); } -#if !wxUSE_UNICODE +#if !wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY inline #endif const char* AsChar() const; @@ -297,8 +297,14 @@ class WXDLLIMPEXP_BASE wxStringPrintfMixinBase protected: wxStringPrintfMixinBase() {} - int DoPrintf(const wxString& format, ...); - static wxString DoFormat(const wxString& format, ...); +#if !wxUSE_UTF8_LOCALE_ONLY + int DoPrintfWchar(const wxChar *format, ...); + static wxString DoFormatWchar(const wxChar *format, ...); +#endif +#if wxUSE_UNICODE_UTF8 + int DoPrintfUtf8(const char *format, ...); + static wxString DoFormatUtf8(const char *format, ...); +#endif }; // this class contains template wrappers for wxString's vararg methods, it's @@ -322,9 +328,9 @@ public: // if !wxNEEDS_WXSTRING_PRINTF_MIXIN: // static wxString Format(const wString& format, ...) ATTRIBUTE_PRINTF_1; - WX_DEFINE_VARARG_FUNC2_SANS_N0(static typename StringReturnType::type, - Format, 1, (const wxString&), - DoFormat, DoFormat) + WX_DEFINE_VARARG_FUNC_SANS_N0(static typename StringReturnType::type, + Format, 1, (const wxFormatString&), + DoFormatWchar, DoFormatUtf8) // We have to implement the version without template arguments manually // because of the StringReturnType<> hack, although WX_DEFINE_VARARG_FUNC // normally does it itself. It has to be a template so that we can use @@ -333,15 +339,17 @@ public: template inline static typename StringReturnType::type - Format(const wxString& fmt, FormatDummyArg dummy = FormatDummyArg()) + Format(const wxFormatString& fmt, FormatDummyArg dummy = FormatDummyArg()) { - return DoFormat(fmt); + return DoFormatWchar(fmt); } // int Printf(const wxString& format, ...); - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&), DoPrintf) + WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&), + DoPrintfWchar, DoPrintfUtf8) // int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2; - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&), DoPrintf) + WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxFormatString&), + DoPrintfWchar, DoPrintfUtf8) protected: wxStringPrintfMixin() : wxStringPrintfMixinBase() {} @@ -469,9 +477,6 @@ private: #else // wxUSE_UNICODE_UTF8 - // FIXME-UTF8: return as-is without copying under UTF8 locale, return - // converted string under other locales - needs wxCharBuffer - // changes static wxCharBuffer ImplStr(const char* str, const wxMBConv& conv = wxConvLibc) { return ConvertStr(str, npos, conv).data; } @@ -923,8 +928,7 @@ public: { return wxStdWideString(wc_str()); } #endif - #if !wxUSE_UNICODE && wxUSE_STL_BASED_WXSTRING - // FIXME-UTF8: do this in UTF8 build #if wxUSE_UTF8_LOCALE_ONLY, too + #if (!wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY) && wxUSE_STL_BASED_WXSTRING // wxStringImpl is std::string in the encoding we want operator const std::string&() const { return m_impl; } #else @@ -933,8 +937,7 @@ public: // FIXME-UTF8: broken for embedded NULs { return std::string(mb_str()); } #endif - -#endif // wxUSE_STD_STRING +#endif // wxUSE_STL // first valid index position const_iterator begin() const { return const_iterator(m_impl.begin()); } @@ -1126,6 +1129,57 @@ public: const char *ToAscii() const { return c_str(); } #endif // Unicode/!Unicode + // conversion to/from UTF-8: +#if wxUSE_UNICODE_UTF8 + static wxString FromUTF8(const char *utf8) + { + wxASSERT( wxStringOperations::IsValidUtf8String(utf8) ); + return FromImpl(wxStringImpl(utf8)); + } + static wxString FromUTF8(const char *utf8, size_t len) + { + wxASSERT( wxStringOperations::IsValidUtf8String(utf8, len) ); + return FromImpl(wxStringImpl(utf8, len)); + } + const char* utf8_str() const { return wx_str(); } + const char* ToUTF8() const { return wx_str(); } +#elif wxUSE_UNICODE_WCHAR + static wxString FromUTF8(const char *utf8) + { return wxString(utf8, wxConvUTF8); } + static wxString FromUTF8(const char *utf8, size_t len) + { return wxString(utf8, wxConvUTF8, len); } + const wxCharBuffer utf8_str() const { return mb_str(wxConvUTF8); } + const wxCharBuffer ToUTF8() const { return utf8_str(); } +#else // ANSI + static wxString FromUTF8(const char *utf8) + { return wxString(wxConvUTF8.cMB2WC(utf8)); } + static wxString FromUTF8(const char *utf8, size_t len) + { + size_t wlen; + wxWCharBuffer buf(wxConvUTF8.cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen)); + return wxString(buf.data(), wlen); + } + const wxCharBuffer utf8_str() const { return wxConvUTF8.cWC2MB(wc_str()); } + const wxCharBuffer ToUTF8() const { return utf8_str(); } +#endif + + // functions for storing binary data in wxString: +#if wxUSE_UNICODE + static wxString From8BitData(const char *data, size_t len) + { return wxString(data, wxConvISO8859_1, len); } + // version for NUL-terminated data: + static wxString From8BitData(const char *data) + { return wxString(data, wxConvISO8859_1); } + const wxCharBuffer To8BitData() const { return mb_str(wxConvISO8859_1); } +#else // ANSI + static wxString From8BitData(const char *data, size_t len) + { return wxString(data, len); } + // version for NUL-terminated data: + static wxString From8BitData(const char *data) + { return wxString(data); } + const char *To8BitData() const { return c_str(); } +#endif // Unicode/ANSI + // conversions with (possible) format conversions: have to return a // buffer with temporary data // @@ -1136,7 +1190,13 @@ public: // type differs because a function may either return pointer to the buffer // directly or have to use intermediate buffer for translation. #if wxUSE_UNICODE + +#if wxUSE_UTF8_LOCALE_ONLY + const char* mb_str() const { return wx_str(); } + const wxCharBuffer mb_str(const wxMBConv& conv) const; +#else const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const; +#endif const wxWX2MBbuf mbc_str() const { return mb_str(*wxConvCurrent); } @@ -1248,13 +1308,8 @@ public: // string += buffer (i.e. from wxGetString) wxString& operator<<(const wxWCharBuffer& s) { return operator<<((const wchar_t *)s); } - wxString& operator+=(const wxWCharBuffer& s) - { return operator<<((const wchar_t *)s); } - wxString& operator<<(const wxCharBuffer& s) { return operator<<((const char *)s); } - wxString& operator+=(const wxCharBuffer& s) - { return operator<<((const char *)s); } // string += C string wxString& Append(const wxString& s) @@ -1266,12 +1321,16 @@ public: append(s); return *this; } - wxString& Append(const wxCStrData& psz) - { append(psz); return *this; } wxString& Append(const char* psz) { append(psz); return *this; } wxString& Append(const wchar_t* pwz) { append(pwz); return *this; } + wxString& Append(const wxCStrData& psz) + { append(psz); return *this; } + wxString& Append(const wxCharBuffer& psz) + { append(psz); return *this; } + wxString& Append(const wxWCharBuffer& psz) + { append(psz); return *this; } // append count copies of given character wxString& Append(wxUniChar ch, size_t count = 1u) { append(count, ch); return *this; } @@ -1353,12 +1412,14 @@ public: { return compare(pwz); } int Cmp(const wxString& s) const { return compare(s); } + int Cmp(const wxCStrData& s) const + { return compare(s); } + int Cmp(const wxCharBuffer& s) const + { return compare(s); } + int Cmp(const wxWCharBuffer& s) const + { return compare(s); } // same as Cmp() but not case-sensitive int CmpNoCase(const wxString& s) const; - int CmpNoCase(const char *psz) const - { return CmpNoCase(wxString(psz)); } - int CmpNoCase(const wchar_t *pwz) const - { return CmpNoCase(wxString(pwz)); } // test for the string equality, either considering case or not // (if compareWithCase then the case matters) bool IsSameAs(const wxString& str, bool compareWithCase = true) const @@ -1367,6 +1428,12 @@ public: { return (compareWithCase ? Cmp(str) : CmpNoCase(str)) == 0; } bool IsSameAs(const wchar_t *str, bool compareWithCase = true) const { return (compareWithCase ? Cmp(str) : CmpNoCase(str)) == 0; } + bool IsSameAs(const wxCStrData& str, bool compareWithCase = true) const + { return IsSameAs(str.AsString(), compareWithCase); } + bool IsSameAs(const wxCharBuffer& str, bool compareWithCase = true) const + { return IsSameAs(str.data(), compareWithCase); } + bool IsSameAs(const wxWCharBuffer& str, bool compareWithCase = true) const + { return IsSameAs(str.data(), compareWithCase); } // comparison with a single character: returns true if equal bool IsSameAs(wxUniChar c, bool compareWithCase = true) const { @@ -1453,7 +1520,6 @@ public: int Find(wchar_t ch, bool bFromEnd = false) const { return Find(wxUniChar(ch), bFromEnd); } // searching (return starting index, or -1 if not found) - // FIXME-UTF8: keep wxString overload only int Find(const wxString& sub) const // like strstr { size_type idx = find(sub); @@ -1470,6 +1536,13 @@ public: return (idx == npos) ? wxNOT_FOUND : (int)idx; } + int Find(const wxCStrData& sub) const + { return Find(sub.AsString()); } + int Find(const wxCharBuffer& sub) const + { return Find(sub.data()); } + int Find(const wxWCharBuffer& sub) const + { return Find(sub.data()); } + // replace first (or all of bReplaceAll) occurences of substring with // another string, returns the number of replacements made size_t Replace(const wxString& strOld, @@ -1503,11 +1576,18 @@ public: // as sprintf(), returns the number of characters written or < 0 on error // (take 'this' into account in attribute parameter count) // int Printf(const wxString& format, ...); - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&), DoPrintf) + WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&), + DoPrintfWchar, DoPrintfUtf8) #ifdef __WATCOMC__ - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const char*), DoPrintf) - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wchar_t*), DoPrintf) - WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxCStrData&), DoPrintf) + // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 + WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxString&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wxCStrData&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const char*), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, Printf, 1, (const wchar_t*), + (wxFormatString(f1))); #endif #endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN // as vprintf(), returns the number of characters written or < 0 on error @@ -1516,12 +1596,18 @@ public: #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN // returns the string containing the result of Printf() to it // static wxString Format(const wxString& format, ...) ATTRIBUTE_PRINTF_1; - WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxString&), DoFormat) + WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxFormatString&), + DoFormatWchar, DoFormatUtf8) #ifdef __WATCOMC__ // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const char*), DoFormat) - WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wchar_t*), DoFormat) - WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxCStrData&), DoFormat) + WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxString&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wxCStrData&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const char*), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(static wxString, Format, 1, (const wchar_t*), + (wxFormatString(f1))); #endif #endif // the same as above, but takes a va_list @@ -1559,12 +1645,18 @@ public: // use Printf() // (take 'this' into account in attribute parameter count) // int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2; - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&), DoPrintf) + WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxFormatString&), + DoPrintfWchar, DoPrintfUtf8) #ifdef __WATCOMC__ // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const char*), DoPrintf) - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wchar_t*), DoPrintf) - WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxCStrData&), DoPrintf) + WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxString&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wxCStrData&), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const char*), + (wxFormatString(f1))); + WX_VARARG_WATCOM_WORKAROUND(int, sprintf, 1, (const wchar_t*), + (wxFormatString(f1))); #endif #endif // wxNEEDS_WXSTRING_PRINTF_MIXIN @@ -1599,7 +1691,6 @@ public: int First( char ch ) const { return Find(ch); } int First( unsigned char ch ) const { return Find(ch); } int First( wchar_t ch ) const { return Find(ch); } - int First( const wxChar* psz ) const { return Find(psz); } int First( const wxString& str ) const { return Find(str); } int Last( wxUniChar ch ) const { return Find(ch, true); } bool Contains(const wxString& str) const { return Find(str) != wxNOT_FOUND; } @@ -1650,8 +1741,6 @@ public: // append a string wxString& append(const wxString& str) { m_impl.append(str.m_impl); return *this; } - wxString& append(const wxCStrData& str) - { m_impl.append(str.AsString().m_impl); return *this; } // append first n (or all if n == npos) characters of sz wxString& append(const char *sz) { m_impl.append(ImplStr(sz)); return *this; } @@ -1669,6 +1758,14 @@ public: m_impl.append(str.data, str.len); return *this; } + + wxString& append(const wxCStrData& str) + { return append(str.AsString()); } + wxString& append(const wxCharBuffer& str) + { return append(str.data()); } + wxString& append(const wxWCharBuffer& str) + { return append(str.data()); } + // append n copies of ch wxString& append(size_t n, wxUniChar ch) { @@ -1725,6 +1822,20 @@ public: m_impl.assign(str.data, str.len); return *this; } + + wxString& assign(const wxCStrData& str) + { return assign(str.AsString()); } + wxString& assign(const wxCharBuffer& str) + { return assign(str.data()); } + wxString& assign(const wxWCharBuffer& str) + { return assign(str.data()); } + wxString& assign(const wxCStrData& str, size_t len) + { return assign(str.AsString(), len); } + wxString& assign(const wxCharBuffer& str, size_t len) + { return assign(str.data(), len); } + wxString& assign(const wxWCharBuffer& str, size_t len) + { return assign(str.data(), len); } + // same as `= n copies of ch' wxString& assign(size_t n, wxUniChar ch) { @@ -1760,14 +1871,19 @@ public: // string comparison int compare(const wxString& str) const; + int compare(const char* sz) const; + int compare(const wchar_t* sz) const; + int compare(const wxCStrData& str) const + { return compare(str.AsString()); } + int compare(const wxCharBuffer& str) const + { return compare(str.data()); } + int compare(const wxWCharBuffer& str) const + { return compare(str.data()); } // comparison with a substring int compare(size_t nStart, size_t nLen, const wxString& str) const; // comparison of 2 substrings int compare(size_t nStart, size_t nLen, const wxString& str, size_t nStart2, size_t nLen2) const; - // just like strcmp() - int compare(const char* sz) const; - int compare(const wchar_t* sz) const; // substring comparison with first nCount characters of sz int compare(size_t nStart, size_t nLen, const char* sz, size_t nCount = npos) const; @@ -2009,6 +2125,12 @@ public: SubstrBufFromWC str(ImplStr(sz, n)); return PosFromImpl(m_impl.find(str.data, PosToImpl(nStart), str.len)); } + size_t find(const wxCharBuffer& s, size_t nStart = 0, size_t n = npos) const + { return find(s.data(), nStart, n); } + size_t find(const wxWCharBuffer& s, size_t nStart = 0, size_t n = npos) const + { return find(s.data(), nStart, n); } + size_t find(const wxCStrData& s, size_t nStart = 0, size_t n = npos) const + { return find(s.AsWChar(), nStart, n); } // find the first occurence of character ch after nStart size_t find(wxUniChar ch, size_t nStart = 0) const @@ -2042,6 +2164,12 @@ public: SubstrBufFromWC str(ImplStr(sz, n)); return PosFromImpl(m_impl.rfind(str.data, PosToImpl(nStart), str.len)); } + size_t rfind(const wxCharBuffer& s, size_t nStart = npos, size_t n = npos) const + { return rfind(s.data(), nStart, n); } + size_t rfind(const wxWCharBuffer& s, size_t nStart = npos, size_t n = npos) const + { return rfind(s.data(), nStart, n); } + size_t rfind(const wxCStrData& s, size_t nStart = npos, size_t n = npos) const + { return rfind(s.AsWChar(), nStart, n); } // as find, but from the end size_t rfind(wxUniChar ch, size_t nStart = npos) const { @@ -2120,9 +2248,9 @@ public: // as strpbrk() but starts at nStart, returns npos if not found size_t find_first_of(const wxString& str, size_t nStart = 0) const #if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_first_of(str.mb_str().data(), nStart); } + { return find_first_of(str.wc_str(), nStart); } #else - { return find_first_of((const wxChar*)str.c_str(), nStart); } + { return find_first_of(str.mb_str(), nStart); } #endif // same as above size_t find_first_of(const char* sz, size_t nStart = 0) const; @@ -2135,9 +2263,9 @@ public: // find the last (starting from nStart) char from str in this string size_t find_last_of (const wxString& str, size_t nStart = npos) const #if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_last_of(str.mb_str().data(), nStart); } + { return find_last_of(str.wc_str(), nStart); } #else - { return find_last_of((const wxChar*)str.c_str(), nStart); } + { return find_last_of(str.mb_str(), nStart); } #endif // same as above size_t find_last_of (const char* sz, size_t nStart = npos) const; @@ -2153,9 +2281,9 @@ public: // as strspn() (starting from nStart), returns npos on failure size_t find_first_not_of(const wxString& str, size_t nStart = 0) const #if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_first_not_of(str.mb_str().data(), nStart); } + { return find_first_not_of(str.wc_str(), nStart); } #else - { return find_first_not_of((const wxChar*)str.c_str(), nStart); } + { return find_first_not_of(str.mb_str(), nStart); } #endif // same as above size_t find_first_not_of(const char* sz, size_t nStart = 0) const; @@ -2167,9 +2295,9 @@ public: // as strcspn() size_t find_last_not_of(const wxString& str, size_t nStart = npos) const #if wxUSE_UNICODE // FIXME-UTF8: temporary - { return find_last_not_of(str.mb_str().data(), nStart); } + { return find_last_not_of(str.wc_str(), nStart); } #else - { return find_last_not_of((const wxChar*)str.c_str(), nStart); } + { return find_last_not_of(str.mb_str(), nStart); } #endif // same as above size_t find_last_not_of(const char* sz, size_t nStart = npos) const; @@ -2215,6 +2343,59 @@ public: size_t find_last_not_of(wchar_t ch, size_t nStart = npos) const { return find_last_not_of(wxUniChar(ch), nStart); } + // and additional overloads for the versions taking strings: + size_t find_first_of(const wxCStrData& sz, size_t nStart = 0) const + { return find_first_of(sz.AsString(), nStart); } + size_t find_first_of(const wxCharBuffer& sz, size_t nStart = 0) const + { return find_first_of(sz.data(), nStart); } + size_t find_first_of(const wxWCharBuffer& sz, size_t nStart = 0) const + { return find_first_of(sz.data(), nStart); } + size_t find_first_of(const wxCStrData& sz, size_t nStart, size_t n) const + { return find_first_of(sz.AsWChar(), nStart, n); } + size_t find_first_of(const wxCharBuffer& sz, size_t nStart, size_t n) const + { return find_first_of(sz.data(), nStart, n); } + size_t find_first_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const + { return find_first_of(sz.data(), nStart, n); } + + size_t find_last_of(const wxCStrData& sz, size_t nStart = 0) const + { return find_last_of(sz.AsString(), nStart); } + size_t find_last_of(const wxCharBuffer& sz, size_t nStart = 0) const + { return find_last_of(sz.data(), nStart); } + size_t find_last_of(const wxWCharBuffer& sz, size_t nStart = 0) const + { return find_last_of(sz.data(), nStart); } + size_t find_last_of(const wxCStrData& sz, size_t nStart, size_t n) const + { return find_last_of(sz.AsWChar(), nStart, n); } + size_t find_last_of(const wxCharBuffer& sz, size_t nStart, size_t n) const + { return find_last_of(sz.data(), nStart, n); } + size_t find_last_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const + { return find_last_of(sz.data(), nStart, n); } + + size_t find_first_not_of(const wxCStrData& sz, size_t nStart = 0) const + { return find_first_not_of(sz.AsString(), nStart); } + size_t find_first_not_of(const wxCharBuffer& sz, size_t nStart = 0) const + { return find_first_not_of(sz.data(), nStart); } + size_t find_first_not_of(const wxWCharBuffer& sz, size_t nStart = 0) const + { return find_first_not_of(sz.data(), nStart); } + size_t find_first_not_of(const wxCStrData& sz, size_t nStart, size_t n) const + { return find_first_not_of(sz.AsWChar(), nStart, n); } + size_t find_first_not_of(const wxCharBuffer& sz, size_t nStart, size_t n) const + { return find_first_not_of(sz.data(), nStart, n); } + size_t find_first_not_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const + { return find_first_not_of(sz.data(), nStart, n); } + + size_t find_last_not_of(const wxCStrData& sz, size_t nStart = 0) const + { return find_last_not_of(sz.AsString(), nStart); } + size_t find_last_not_of(const wxCharBuffer& sz, size_t nStart = 0) const + { return find_last_not_of(sz.data(), nStart); } + size_t find_last_not_of(const wxWCharBuffer& sz, size_t nStart = 0) const + { return find_last_not_of(sz.data(), nStart); } + size_t find_last_not_of(const wxCStrData& sz, size_t nStart, size_t n) const + { return find_last_not_of(sz.AsWChar(), nStart, n); } + size_t find_last_not_of(const wxCharBuffer& sz, size_t nStart, size_t n) const + { return find_last_not_of(sz.data(), nStart, n); } + size_t find_last_not_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const + { return find_last_not_of(sz.data(), nStart, n); } + // string += string wxString& operator+=(const wxString& s) { m_impl += s.m_impl; return *this; } @@ -2225,6 +2406,10 @@ public: { m_impl += ImplStr(pwz); return *this; } wxString& operator+=(const wxCStrData& s) { m_impl += s.AsString().m_impl; return *this; } + wxString& operator+=(const wxCharBuffer& s) + { return operator+=(s.data()); } + wxString& operator+=(const wxWCharBuffer& s) + { return operator+=(s.data()); } // string += char wxString& operator+=(wxUniChar ch) { m_impl += wxStringOperations::EncodeChar(ch); return *this; } @@ -2246,8 +2431,14 @@ private: #endif // !wxUSE_STL_BASED_WXSTRING #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN - int DoPrintf(const wxString& format, ...); - static wxString DoFormat(const wxString& format, ...); + #if !wxUSE_UTF8_LOCALE_ONLY + int DoPrintfWchar(const wxChar *format, ...); + static wxString DoFormatWchar(const wxChar *format, ...); + #endif + #if wxUSE_UNICODE_UTF8 + int DoPrintfUtf8(const char *format, ...); + static wxString DoFormatUtf8(const char *format, ...); + #endif #endif #if !wxUSE_STL_BASED_WXSTRING @@ -2279,7 +2470,7 @@ private: T *m_buf; }; -#if wxUSE_UNICODE +#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY ConvertedBuffer m_convertedToChar; #endif #if !wxUSE_UNICODE_WCHAR @@ -2672,10 +2863,10 @@ inline const wchar_t* wxCStrData::AsWChar() const } #endif // wxUSE_UNICODE_WCHAR -#if !wxUSE_UNICODE +#if !wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY inline const char* wxCStrData::AsChar() const { - return m_str->wx_str() + m_offset; + return wxStringOperations::AddToIter(m_str->wx_str(), m_offset); } #endif // !wxUSE_UNICODE