From ba98e032a7d195fc94d3856bcd8f4cf4b4b01b4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 2 Jun 2007 12:42:57 +0000 Subject: [PATCH] implemented wxMBConv::IsUTF8() helper for more classes so that all uses of UTF-8 are detected and optimized in wxString git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46265 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/strconv.h | 8 ++++++++ src/common/strconv.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 0fbe71bfd5..d953b892af 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -223,6 +223,10 @@ public: return m_conv->GetMBNulLen(); } +#if wxUSE_UNICODE_UTF8 + virtual bool IsUTF8() const { return m_conv->IsUTF8(); } +#endif + virtual wxMBConv *Clone() const { return new wxConvBrokenFileNames(*this); } private: @@ -399,6 +403,10 @@ public: virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const; virtual size_t GetMBNulLen() const; +#if wxUSE_UNICODE_UTF8 + virtual bool IsUTF8() const; +#endif + virtual wxMBConv *Clone() const { return new wxCSConv(*this); } void Clear(); diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index cd673cd72d..408b9f2906 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1597,6 +1597,10 @@ public: // classify this encoding as explained in wxMBConv::GetMBNulLen() comment virtual size_t GetMBNulLen() const; +#if wxUSE_UNICODE_UTF8 + virtual bool IsUTF8() const; +#endif + virtual wxMBConv *Clone() const { wxMBConv_iconv *p = new wxMBConv_iconv(m_name); @@ -1975,6 +1979,14 @@ size_t wxMBConv_iconv::GetMBNulLen() const return m_minMBCharWidth; } +#if wxUSE_UNICODE_UTF8 +bool wxMBConv_iconv::IsUTF8() const +{ + return wxStricmp(m_name, "UTF-8") == 0 || + wxStricmp(m_name, "UTF8") == 0; +} +#endif + #endif // HAVE_ICONV @@ -3613,9 +3625,25 @@ size_t wxCSConv::GetMBNulLen() const return m_convReal->GetMBNulLen(); } + // otherwise, we are ISO-8859-1 return 1; } +#if wxUSE_UNICODE_UTF8 +bool wxCSConv::IsUTF8() const +{ + CreateConvIfNeeded(); + + if ( m_convReal ) + { + return m_convReal->IsUTF8(); + } + + // otherwise, we are ISO-8859-1 + return false; +} +#endif + #if wxUSE_UNICODE -- 2.47.2