X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bb67b808b1c375b8ebea4688d44bcbe2d4976d3..e97f6ab64ef2e1e3839114d95ad6b60b7ac5bd27:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 4b42a151b1..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 size_t MB2WC(wchar_t *buf, const char *psz, size_t n); - virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n); + 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 @@ -444,11 +472,16 @@ public: wxString& operator=(wxChar ch); // from a C string wxString& operator=(const wxChar *psz); -#if !wxUSE_UNICODE +#if wxUSE_UNICODE + // from wxWCharBuffer + wxString& operator=(const wxWCharBuffer& psz) { return operator=((const wchar_t *)psz); } +#else // from another kind of C string wxString& operator=(const unsigned char* psz); // from a wide string wxString& operator=(const wchar_t *pwz); + // from wxCharBuffer + wxString& operator=(const wxCharBuffer& psz) { return operator=((const char *)psz); } #endif // string concatenation @@ -970,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