X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7929902d65215d481c59733a5d05b81e373b8237..b53aea81d2e102224b452ef5bf7aee1132f37c6f:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index 5729c48c65..56af51ae22 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -50,6 +50,18 @@ #define wxStringStrlen wxStrlen #endif +// ---------------------------------------------------------------------------- +// global variables +// ---------------------------------------------------------------------------- + +namespace wxPrivate +{ + +static UntypedBufferData s_untypedNullData(NULL); + +UntypedBufferData * const untypedNullDataPtr = &s_untypedNullData; + +} // namespace wxPrivate // --------------------------------------------------------------------------- // static class variables definition @@ -168,7 +180,13 @@ static wxStrCacheStatsDumper s_showCacheStats; wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) { #if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 - return os << (const char *)str.AsCharBuf(); + const wxCharBuffer buf(str.AsCharBuf()); + if ( !buf ) + os.clear(wxSTD ios_base::failbit); + else + os << buf.data(); + + return os; #else return os << str.AsInternal(); #endif @@ -1097,6 +1115,7 @@ size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart, int wxString::CmpNoCase(const wxString& s) const { +#if wxUSE_UNICODE_UTF8 // FIXME-UTF8: use wxUniChar::ToLower/ToUpper once added const_iterator i1 = begin(); @@ -1120,6 +1139,9 @@ int wxString::CmpNoCase(const wxString& s) const else if ( len1 > len2 ) return 1; return 0; +#else // wxUSE_UNICODE_WCHAR or ANSI + return wxStricmp(m_impl.c_str(), s.m_impl.c_str()); +#endif } @@ -2091,47 +2113,3 @@ int wxString::Freq(wxUniChar ch) const return count; } -// ---------------------------------------------------------------------------- -// wxUTF8StringBuffer -// ---------------------------------------------------------------------------- - -#if wxUSE_UNICODE_WCHAR -wxUTF8StringBuffer::~wxUTF8StringBuffer() -{ - wxMBConvStrictUTF8 conv; - size_t wlen = conv.ToWChar(NULL, 0, m_buf); - wxCHECK_RET( wlen != wxCONV_FAILED, "invalid UTF-8 data in string buffer?" ); - - wxStringInternalBuffer wbuf(m_str, wlen); - conv.ToWChar(wbuf, wlen, m_buf); -} - -wxUTF8StringBufferLength::~wxUTF8StringBufferLength() -{ - wxCHECK_RET(m_lenSet, "length not set"); - - wxMBConvStrictUTF8 conv; - size_t wlen = conv.ToWChar(NULL, 0, m_buf, m_len); - wxCHECK_RET( wlen != wxCONV_FAILED, "invalid UTF-8 data in string buffer?" ); - - wxStringInternalBufferLength wbuf(m_str, wlen); - conv.ToWChar(wbuf, wlen, m_buf, m_len); - wbuf.SetLength(wlen); -} -#endif // wxUSE_UNICODE_WCHAR - -// ---------------------------------------------------------------------------- -// wxCharBufferType -// ---------------------------------------------------------------------------- - -#ifndef __VMS_BROKEN_TEMPLATES -template<> -#endif -wxCharTypeBuffer::Data -wxCharTypeBuffer::NullData(NULL); - -#ifndef __VMS_BROKEN_TEMPLATES -template<> -#endif -wxCharTypeBuffer::Data -wxCharTypeBuffer::NullData(NULL);