backported wxString::From/ToUTF8 to 2.8 for forward compatibility with wx3

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-06 12:57:43 +00:00
parent a7f6f72906
commit 1ec1052865
3 changed files with 60 additions and 5 deletions

View File

@@ -863,6 +863,30 @@ public:
const char *ToAscii() const { return c_str(); }
#endif // Unicode/!Unicode
#if wxABI_VERSION >= 20804
// conversion to/from UTF-8:
#if wxUSE_UNICODE
static wxString FromUTF8(const char *utf8)
{ return wxString(utf8, wxConvUTF8); }
static wxString FromUTF8(const char *utf8, size_t len)
{ return wxString(utf8, wxConvUTF8, len); }
const wxCharBuffer utf8_str() const { return mb_str(wxConvUTF8); }
const wxCharBuffer ToUTF8() const { return utf8_str(); }
#elif wxUSE_WCHAR_T // ANSI
static wxString FromUTF8(const char *utf8)
{ return wxString(wxConvUTF8.cMB2WC(utf8)); }
static wxString FromUTF8(const char *utf8, size_t len)
{
size_t wlen;
wxWCharBuffer buf(wxConvUTF8.cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
return wxString(buf.data(), wxConvLibc, wlen);
}
const wxCharBuffer utf8_str() const
{ return wxConvUTF8.cWC2MB(wc_str(wxConvLibc)); }
const wxCharBuffer ToUTF8() const { return utf8_str(); }
#endif // Unicode/ANSI
#endif // wxABI_VERSION >= 20804
#if wxABI_VERSION >= 20804
// functions for storing binary data in wxString:
#if wxUSE_UNICODE