X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2730723380b41dd1020e19cee33adfa993e2940c..7822ffb1de54dbb0b89e03c3bae89a5ee91c7169:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 599048e9e2..d442253f35 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -28,8 +28,6 @@ #include "wx/strconv.h" -#if wxUSE_WCHAR_T - #ifndef __WXWINCE__ #include #endif @@ -539,7 +537,7 @@ const wxWCharBuffer wxMBConv::cMB2WC(const wxScopedCharBuffer& buf) const } } - return wxWCharBuffer(); + return wxScopedWCharBuffer::CreateNonOwned(L"", 0); } const wxCharBuffer wxMBConv::cWC2MB(const wxScopedWCharBuffer& wbuf) const @@ -557,7 +555,7 @@ const wxCharBuffer wxMBConv::cWC2MB(const wxScopedWCharBuffer& wbuf) const } } - return wxCharBuffer(); + return wxScopedCharBuffer::CreateNonOwned("", 0); } // ---------------------------------------------------------------------------- @@ -2115,7 +2113,7 @@ public: virtual wxMBConv *Clone() const { - wxMBConv_iconv *p = new wxMBConv_iconv(m_name.ToAscii()); + wxMBConv_iconv *p = new wxMBConv_iconv(m_name); p->m_minMBCharWidth = m_minMBCharWidth; return p; } @@ -2145,7 +2143,7 @@ private: // name of the encoding handled by this conversion - wxString m_name; + const char *m_name; // cached result of GetMBNulLen(); set to 0 meaning "unknown" // initially @@ -2169,7 +2167,7 @@ wxString wxMBConv_iconv::ms_wcCharsetName; bool wxMBConv_iconv::ms_wcNeedsSwap = false; wxMBConv_iconv::wxMBConv_iconv(const char *name) - : m_name(name) + : m_name(wxStrdup(name)) { m_minMBCharWidth = 0; @@ -2286,6 +2284,8 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name) wxMBConv_iconv::~wxMBConv_iconv() { + free(const_cast(m_name)); + if ( m2w != ICONV_T_INVALID ) iconv_close(m2w); if ( w2m != ICONV_T_INVALID ) @@ -3015,10 +3015,9 @@ wxCSConv& wxCSConv::operator=(const wxCSConv& conv) void wxCSConv::Clear() { free(m_name); - delete m_convReal; + wxDELETE(m_convReal); m_name = NULL; - m_convReal = NULL; } void wxCSConv::SetName(const char *charset) @@ -3230,7 +3229,7 @@ void wxCSConv::CreateConvIfNeeded() const { if ( m_deferred ) { - wxCSConv *self = (wxCSConv *)this; // const_cast + wxCSConv *self = const_cast(this); // if we don't have neither the name nor the encoding, use the default // encoding for this system @@ -3444,8 +3443,9 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent = wxGet_wxConvLibcPtr(); WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI = wxGet_wxConvLocalPtr(); #ifdef __DARWIN__ -// The xnu kernel always communicates file paths in decomposed UTF-8. -// WARNING: Are we sure that CFString's conversion will cause decomposition? +// It is important to use this conversion object under Darwin as it ensures +// that Unicode strings are (re)composed correctly even though xnu kernel uses +// decomposed form internally (at least for the file names). static wxMBConv_cf wxConvMacUTF8DObj(wxFONTENCODING_UTF8); #endif @@ -3455,14 +3455,3 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = #else // !__DARWIN__ wxGet_wxConvLibcPtr(); #endif // __DARWIN__/!__DARWIN__ - -#else // !wxUSE_WCHAR_T - -// FIXME-UTF8: remove this, wxUSE_WCHAR_T is required now -// stand-ins in absence of wchar_t -WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, - wxConvISO8859_1, - wxConvLocal, - wxConvUTF8; - -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T