X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/111d99489d509bc96819877b88596474f3253859..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/include/wx/stringops.h diff --git a/include/wx/stringops.h b/include/wx/stringops.h index ed53532d9e..2e36900adc 100644 --- a/include/wx/stringops.h +++ b/include/wx/stringops.h @@ -40,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, @@ -72,7 +70,7 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 #endif // table of offsets to skip forward when iterating over UTF-8 sequence - static unsigned char ms_utf8IterTable[256]; + static const unsigned char ms_utf8IterTable[256]; template @@ -142,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); @@ -163,7 +156,15 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 } // decodes single UTF-8 character from UTF-8 string - static wxUniChar DecodeChar(wxStringImpl::const_iterator i); + static wxUniChar DecodeChar(wxStringImpl::const_iterator i) + { + if ( (unsigned char)*i < 0x80 ) + return (int)*i; + return DecodeNonAsciiChar(i); + } + +private: + static wxUniChar DecodeNonAsciiChar(wxStringImpl::const_iterator i); }; #endif // wxUSE_UNICODE_UTF8