X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17a1ebd101f0653e69736416a2a28d0ada423141..89c831801467203372b6964a785823f19e8063dd:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 63de22405c..c55469c0a2 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: strconv.cpp +// Name: src/common/strconv.cpp // Purpose: Unicode conversion classes // Author: Ove Kaaven, Robert Roebling, Vadim Zeitlin, Vaclav Slavik, // Ryan Norton, Fredrik Roubert (UTF7) @@ -78,6 +78,10 @@ #define TRACE_STRCONV _T("strconv") +#if SIZEOF_WCHAR_T == 2 + #define WC_UTF16 +#endif + // ============================================================================ // implementation // ============================================================================ @@ -653,7 +657,7 @@ size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const } #else // !WC_UTF16 if (buf) - *buf++ = res; + *buf++ = (wchar_t)res; len++; #endif // WC_UTF16/!WC_UTF16 } @@ -674,7 +678,7 @@ size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const len += pa; #else if (buf) - *buf++ = wxUnicodePUA + (unsigned char)*opsz; + *buf++ = (wchar_t)(wxUnicodePUA + (unsigned char)*opsz); opsz++; len++; #endif @@ -902,7 +906,7 @@ size_t wxMBConvUTF16straight::MB2WC(wchar_t *buf, const char *psz, size_t n) con return pa; if (buf) - *buf++ = cc; + *buf++ = (wchar_t)cc; len++; psz += pa * sizeof(wxUint16); } @@ -962,7 +966,7 @@ size_t wxMBConvUTF16swap::MB2WC(wchar_t *buf, const char *psz, size_t n) const return pa; if (buf) - *buf++ = cc; + *buf++ = (wchar_t)cc; len++; psz += pa * sizeof(wxUint16); @@ -1163,7 +1167,7 @@ size_t wxMBConvUTF32straight::MB2WC(wchar_t *buf, const char *psz, size_t n) con while (*(wxUint32*)psz && (!buf || len < n)) { if (buf) - *buf++ = *(wxUint32*)psz; + *buf++ = (wchar_t)(*(wxUint32*)psz); len++; psz += sizeof(wxUint32); } @@ -1349,6 +1353,8 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) // check for charset that represents wchar_t: if ( ms_wcCharsetName.empty() ) { + wxLogTrace(TRACE_STRCONV, _T("Looking for wide char codeset:")); + #if wxUSE_FONTMAP const wxChar **names = wxFontMapperBase::GetAllEncodingNames(WC_ENC); #else // !wxUSE_FONTMAP @@ -1363,7 +1369,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) }; #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP - for ( ; *names; ++names ) + for ( ; *names && ms_wcCharsetName.empty(); ++names ) { const wxString nameCS(*names); @@ -1375,10 +1381,15 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name) nameXE += _T("LE"); #endif + wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""), + nameXE.c_str()); + m2w = iconv_open(nameXE.ToAscii(), cname); if ( m2w == ICONV_T_INVALID ) { // try charset w/o bytesex info (e.g. "UCS4") + wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""), + nameCS.c_str()); m2w = iconv_open(nameCS.ToAscii(), cname); // and check for bytesex ourselves: @@ -1584,7 +1595,6 @@ size_t wxMBConv_iconv::WC2MB(char *buf, const wchar_t *psz, size_t n) const if (ICONV_FAILED(cres, inbuf)) { - //VS: it is ok if iconv fails, hence trace only wxLogTrace(TRACE_STRCONV, wxT("iconv failed: %s"), wxSysErrorMsg(wxSysErrorCode())); return (size_t)-1; } @@ -2839,5 +2849,3 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, wxConvUTF8; #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T - -