+ // also provide unsigned char overloads as signed/unsigned doesn't matter
+ // for 7 bit ASCII characters
+ static wxString FromAscii(const unsigned char *ascii)
+ { return FromAscii((const char *)ascii); }
+ static wxString FromAscii(const unsigned char *ascii, size_t len)
+ { return FromAscii((const char *)ascii, len); }
+
+ // conversion to/from UTF-8:
+#if wxUSE_UNICODE_UTF8
+ static wxString FromUTF8(const char *utf8)
+ {
+ if ( !utf8 )
+ return wxEmptyString;
+
+ wxASSERT( wxStringOperations::IsValidUtf8String(utf8) );
+ return FromImpl(wxStringImpl(utf8));
+ }
+ static wxString FromUTF8(const char *utf8, size_t len)
+ {
+ if ( !utf8 )
+ return wxEmptyString;
+ if ( len == npos )
+ return FromUTF8(utf8);
+
+ wxASSERT( wxStringOperations::IsValidUtf8String(utf8, len) );
+ return FromImpl(wxStringImpl(utf8, len));
+ }
+ const char* utf8_str() const { return wx_str(); }
+ const char* ToUTF8() const { return wx_str(); }
+#elif wxUSE_UNICODE_WCHAR
+ static wxString FromUTF8(const char *utf8)
+ { return wxString(utf8, wxMBConvUTF8()); }
+ static wxString FromUTF8(const char *utf8, size_t len)
+ { return wxString(utf8, wxMBConvUTF8(), len); }
+ const wxCharBuffer utf8_str() const { return mb_str(wxMBConvUTF8()); }
+ const wxCharBuffer ToUTF8() const { return utf8_str(); }
+#else // ANSI
+ static wxString FromUTF8(const char *utf8)
+ { return wxString(wxMBConvUTF8().cMB2WC(utf8)); }
+ static wxString FromUTF8(const char *utf8, size_t len)
+ {
+ size_t wlen;
+ wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
+ return wxString(buf.data(), wlen);
+ }
+ const wxCharBuffer utf8_str() const
+ { return wxMBConvUTF8().cWC2MB(wc_str()); }
+ const wxCharBuffer ToUTF8() const { return utf8_str(); }
+#endif
+