+#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
+const char* wxCStrData::AsChar() const
+{
+#if wxUSE_UNICODE_UTF8
+    if ( wxLocaleIsUtf8 )
+        return AsInternal();
+#endif
+    // under non-UTF8 locales, we have to convert the internal UTF-8
+    // representation using wxConvLibc and cache the result
+
+    wxString *str = wxConstCast(m_str, wxString);
+
+    // convert the string:
+    //
+    // FIXME-UTF8: we'd like to do the conversion in the existing buffer (if we
+    //             have it) but it's unfortunately not obvious to implement
+    //             because we don't know how big buffer do we need for the
+    //             given string length (in case of multibyte encodings, e.g.
+    //             ISO-2022-JP or UTF-8 when internal representation is wchar_t)
+    //
+    //             One idea would be to store more than just m_convertedToChar
+    //             in wxString: then we could record the length of the string
+    //             which was converted the last time and try to reuse the same
+    //             buffer if the current length is not greater than it (this
+    //             could still fail because string could have been modified in
+    //             place but it would work most of the time, so we'd do it and
+    //             only allocate the new buffer if in-place conversion returned
+    //             an error). We could also store a bit saying if the string
+    //             was modified since the last conversion (and update it in all
+    //             operation modifying the string, of course) to avoid unneeded
+    //             consequential conversions. But both of these ideas require
+    //             adding more fields to wxString and require profiling results
+    //             to be sure that we really gain enough from them to justify
+    //             doing it.
+    wxCharBuffer buf(str->mb_str());
+
+    // if it failed, return empty string and not NULL to avoid crashes in code
+    // written with either wxWidgets 2 wxString or std::string behaviour in
+    // mind: neither of them ever returns NULL and so we shouldn't neither
+    if ( !buf )
+        return "";
+
+    if ( str->m_convertedToChar &&
+         strlen(buf) == strlen(str->m_convertedToChar) )
+    {
+        // keep the same buffer for as long as possible, so that several calls
+        // to c_str() in a row still work:
+        strcpy(str->m_convertedToChar, buf);
+    }
+    else
+    {
+        str->m_convertedToChar = buf.release();
+    }
+
+    // and keep it:
+    return str->m_convertedToChar + m_offset;
+}
+#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
+
+#if !wxUSE_UNICODE_WCHAR
+const wchar_t* wxCStrData::AsWChar() const
+{
+    wxString *str = wxConstCast(m_str, wxString);
+
+    // convert the string:
+    wxWCharBuffer buf(str->wc_str());
+
+    // notice that here, unlike above in AsChar(), conversion can't fail as our
+    // internal UTF-8 is always well-formed -- or the string was corrupted and
+    // all bets are off anyhow
+
+    // FIXME-UTF8: do the conversion in-place in the existing buffer
+    if ( str->m_convertedToWChar &&
+         wxWcslen(buf) == wxWcslen(str->m_convertedToWChar) )
+    {
+        // keep the same buffer for as long as possible, so that several calls
+        // to c_str() in a row still work:
+        memcpy(str->m_convertedToWChar, buf, sizeof(wchar_t) * wxWcslen(buf));
+    }
+    else
+    {
+        str->m_convertedToWChar = buf.release();
+    }
+
+    // and keep it:
+    return str->m_convertedToWChar + m_offset;
+}
+#endif // !wxUSE_UNICODE_WCHAR
+
+// ===========================================================================
+// wxString class core
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// construction and conversion
+// ---------------------------------------------------------------------------
+
+#if wxUSE_UNICODE_WCHAR