X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2523e9b70044baa92a1c63ffdfe179c28ad53536..5814e8ba4e57839acd1eb7491ed392b07e382593:/include/wx/stringops.h diff --git a/include/wx/stringops.h b/include/wx/stringops.h index 972b832717..b8ba8abd74 100644 --- a/include/wx/stringops.h +++ b/include/wx/stringops.h @@ -15,6 +15,7 @@ #include "wx/chartype.h" #include "wx/stringimpl.h" #include "wx/unichar.h" +#include "wx/buffer.h" // This header contains wxStringOperations "namespace" class that implements // elementary operations on string data as static methods; wxString methods and @@ -39,8 +40,6 @@ struct WXDLLIMPEXP_BASE wxStringOperationsWchar { return i + n; } static wxStringImpl::const_iterator AddToIter(const wxStringImpl::const_iterator& i, int n) { return i + n; } - static const wxChar* AddToIter(const wxChar *i, int n) - { return i + n; } // returns distance of the two iterators in Unicode characters static int DiffIters(const wxStringImpl::iterator& i1, @@ -64,7 +63,8 @@ struct WXDLLIMPEXP_BASE wxStringOperationsWchar struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 { // checks correctness of UTF-8 sequence - static bool IsValidUtf8String(const char *c); + static bool IsValidUtf8String(const char *c, + size_t len = wxStringImpl::npos); #ifdef __WXDEBUG__ static bool IsValidUtf8LeadByte(unsigned char c); #endif @@ -140,15 +140,10 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 return dist; } - // buffer for single UTF-8 character - struct Utf8CharBuffer - { - char data[5]; - operator const char*() const { return data; } - }; - // encodes the character as UTF-8: - static Utf8CharBuffer EncodeChar(const wxUniChar& ch); + typedef wxUniChar::Utf8CharBuffer Utf8CharBuffer; + static Utf8CharBuffer EncodeChar(const wxUniChar& ch) + { return ch.AsUTF8(); } // returns n copies of ch encoded in UTF-8 string static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);