X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/111bb7f2ea92a2d323bd27b833aaad7d9b13ac0b..853d7d3dc9a1f7512a3b71c76b95048c3af6ab02:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index ac53c0dd08..36f6a3773e 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -200,19 +200,42 @@ class WXDLLEXPORT wxMBConv const wxWCharBuffer cWX2WC(const char *psz) const { return cMB2WC(psz); } #endif }; -WXDLLEXPORT_DATA(extern wxMBConv) wxConv_libc, wxConv_UTF7, wxConv_UTF8; -#define wxConv_file wxConv_libc +WXDLLEXPORT_DATA(extern wxMBConv) wxConv_libc; -class WXDLLEXPORT wxCSConv : wxMBConv +#define wxANOTHER_MBCONV(type) \ +class type : public wxMBConv { \ + public: \ + virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const; \ + virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; \ +} + +WXDLLEXPORT_DATA(extern wxANOTHER_MBCONV(wxMBConv_file)) wxConv_file; +WXDLLEXPORT_DATA(extern wxANOTHER_MBCONV(wxMBConv_UTF7)) wxConv_UTF7; +WXDLLEXPORT_DATA(extern wxANOTHER_MBCONV(wxMBConv_UTF8)) wxConv_UTF8; +#if defined(__WXGTK__) && (GTK_MINOR_VERSION > 0) + WXDLLEXPORT_DATA(extern wxANOTHER_MBCONV(wxMBConv_gdk)) wxConv_gdk; +#endif // GTK > 1.0 + +class wxCharacterSet; +class WXDLLEXPORT wxCSConv : public wxMBConv { private: - wxChar *data; + wxChar *m_name; + wxCharacterSet *m_cset; + bool m_deferred; + void SetName(const wxChar *charset); public: wxCSConv(const wxChar *charset); + virtual ~wxCSConv(); + void LoadNow(); virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const; virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; }; +WXDLLEXPORT_DATA(extern wxCSConv) wxConv_local; + +WXDLLEXPORT_DATA(extern wxMBConv *) wxConv_current; + // filenames are multibyte on Unix and probably widechar on Windows? #ifdef __UNIX__ #define wxMBFILES 1 @@ -340,6 +363,9 @@ public: // from C string (for compilers using unsigned char) wxString(const unsigned char* psz, size_t nLength = wxSTRING_MAXLEN) { InitWith((const char*)psz, 0, nLength); } + // from multibyte string + wxString(const char *psz, wxMBConv& WXUNUSED(conv), size_t nLength = wxSTRING_MAXLEN) + { InitWith(psz, 0, nLength); } // from wide (Unicode) string wxString(const wchar_t *pwz); // from wxCharBuffer @@ -436,6 +462,8 @@ public: const wxWCharBuffer wc_str(wxMBConv& conv) const { return conv.cMB2WC(m_pchData); } const wxChar* fn_str() const { return m_pchData; } #endif + // for convenience + const wxWX2MBbuf mbc_str() const { return mb_str(*wxConv_current); } // overloaded assignment // from another wxString @@ -975,6 +1003,17 @@ wxString WXDLLEXPORT operator+(const wxString& string, wxChar ch); wxString WXDLLEXPORT operator+(wxChar ch, const wxString& string); wxString WXDLLEXPORT operator+(const wxString& string, const wxChar *psz); wxString WXDLLEXPORT operator+(const wxChar *psz, const wxString& string); +#if wxUSE_UNICODE +inline wxString WXDLLEXPORT operator+(const wxString& string, const wxWCharBuffer& buf) +{ return string + (const wchar_t *)buf; } +inline wxString WXDLLEXPORT operator+(const wxWCharBuffer& buf, const wxString& string) +{ return (const wchar_t *)buf + string; } +#else +inline wxString WXDLLEXPORT operator+(const wxString& string, const wxCharBuffer& buf) +{ return string + (const char *)buf; } +inline wxString WXDLLEXPORT operator+(const wxCharBuffer& buf, const wxString& string) +{ return (const char *)buf + string; } +#endif // --------------------------------------------------------------------------- // Implementation only from here until the end of file