Always enable wxMBConv::IsUTF8()

These where previously guarded by wxUSE_UNICODE_UTF8 but
may be useful in other configurations too.
This commit is contained in:
Tobias Taschner
2017-10-27 19:57:51 +02:00
parent 0cb55df404
commit 73a22766ee
5 changed files with 7 additions and 26 deletions

View File

@@ -133,12 +133,10 @@ public:
// encoding
static size_t GetMaxMBNulLen() { return 4 /* for UTF-32 */; }
#if wxUSE_UNICODE_UTF8
// return true if the converter's charset is UTF-8, i.e. char* strings
// decoded using this object can be directly copied to wxString's internal
// storage without converting to WC and than back to UTF-8 MB string
virtual bool IsUTF8() const { return false; }
#endif
// The old conversion functions. The existing classes currently mostly
// implement these ones but we're in transition to using To/FromWChar()
@@ -180,9 +178,7 @@ public:
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxMBConvLibc; }
#if wxUSE_UNICODE_UTF8
virtual bool IsUTF8() const wxOVERRIDE { return wxLocaleIsUtf8; }
#endif
};
#ifdef __UNIX__
@@ -221,9 +217,7 @@ public:
return m_conv->GetMBNulLen();
}
#if wxUSE_UNICODE_UTF8
virtual bool IsUTF8() const wxOVERRIDE { return m_conv->IsUTF8(); }
#endif
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxConvBrokenFileNames(*this); }
@@ -342,11 +336,9 @@ public:
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxMBConvStrictUTF8(); }
#if wxUSE_UNICODE_UTF8
// NB: other mapping modes are not, strictly speaking, UTF-8, so we can't
// take the shortcut in that case
virtual bool IsUTF8() const wxOVERRIDE { return true; }
#endif
};
class WXDLLIMPEXP_BASE wxMBConvUTF8 : public wxMBConvStrictUTF8
@@ -368,11 +360,9 @@ public:
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxMBConvUTF8(m_options); }
#if wxUSE_UNICODE_UTF8
// NB: other mapping modes are not, strictly speaking, UTF-8, so we can't
// take the shortcut in that case
virtual bool IsUTF8() const wxOVERRIDE { return m_options == MAP_INVALID_UTF8_NOT; }
#endif
private:
int m_options;
@@ -496,9 +486,7 @@ public:
const wchar_t *src, size_t srcLen = wxNO_LEN) const wxOVERRIDE;
virtual size_t GetMBNulLen() const wxOVERRIDE;
#if wxUSE_UNICODE_UTF8
virtual bool IsUTF8() const wxOVERRIDE;
#endif
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxCSConv(*this); }

View File

@@ -75,7 +75,6 @@
------------------------------------------------------------------------- */
#ifdef __cplusplus
#if wxUSE_UNICODE_UTF8
/* flag indicating whether the current locale uses UTF-8 or not; must be
updated every time the locale is changed! */
#if wxUSE_UTF8_LOCALE_ONLY
@@ -85,9 +84,6 @@
#endif
/* function used to update the flag: */
extern WXDLLIMPEXP_BASE void wxUpdateLocaleIsUtf8();
#else /* !wxUSE_UNICODE_UTF8 */
inline void wxUpdateLocaleIsUtf8() {}
#endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */
#endif /* __cplusplus */

View File

@@ -68,6 +68,13 @@ public:
*/
static size_t GetMaxMBNulLen();
/**
return true if the converter's charset is UTF-8, i.e. char* strings
decoded using this object can be directly copied to wxString's internal
storage without converting to WC and than back to UTF-8 MB string
*/
virtual bool IsUTF8() const;
/**
Convert multibyte string to a wide character one.

View File

@@ -2128,9 +2128,7 @@ public:
const wchar_t *src, size_t srcLen = wxNO_LEN) const wxOVERRIDE;
virtual size_t GetMBNulLen() const wxOVERRIDE;
#if wxUSE_UNICODE_UTF8
virtual bool IsUTF8() const wxOVERRIDE;
#endif
virtual wxMBConv *Clone() const wxOVERRIDE
{
@@ -2516,13 +2514,11 @@ 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
@@ -3250,7 +3246,6 @@ size_t wxCSConv::GetMBNulLen() const
return 1;
}
#if wxUSE_UNICODE_UTF8
bool wxCSConv::IsUTF8() const
{
if ( m_convReal )
@@ -3259,7 +3254,6 @@ bool wxCSConv::IsUTF8() const
// otherwise, we are ISO-8859-1
return false;
}
#endif
// ============================================================================

View File

@@ -1091,8 +1091,6 @@ char *strdup(const char *s)
// wxLocaleIsUtf8
// ============================================================================
#if wxUSE_UNICODE_UTF8
#if !wxUSE_UTF8_LOCALE_ONLY
bool wxLocaleIsUtf8 = false; // the safer setting if not known
#endif
@@ -1147,8 +1145,6 @@ void wxUpdateLocaleIsUtf8()
#endif
}
#endif // wxUSE_UNICODE_UTF8
// ============================================================================
// wx wrappers for CRT functions
// ============================================================================