don't use implicit wxString->char*/wchar_t* conversion, it will not be available in wxUSE_STL build in the future
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -476,10 +476,10 @@ size_t wxMBConvLibc::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
||||
|
||||
#ifdef __UNIX__
|
||||
|
||||
wxConvBrokenFileNames::wxConvBrokenFileNames(const wxChar *charset)
|
||||
wxConvBrokenFileNames::wxConvBrokenFileNames(const wxString& charset)
|
||||
{
|
||||
if ( !charset || wxStricmp(charset, _T("UTF-8")) == 0
|
||||
|| wxStricmp(charset, _T("UTF8")) == 0 )
|
||||
if ( wxStricmp(charset, _T("UTF-8")) == 0 ||
|
||||
wxStricmp(charset, _T("UTF8")) == 0 )
|
||||
m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA);
|
||||
else
|
||||
m_conv = new wxCSConv(charset);
|
||||
@@ -1588,7 +1588,7 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen,
|
||||
class wxMBConv_iconv : public wxMBConv
|
||||
{
|
||||
public:
|
||||
wxMBConv_iconv(const wxChar *name);
|
||||
wxMBConv_iconv(const char *name);
|
||||
virtual ~wxMBConv_iconv();
|
||||
|
||||
virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const;
|
||||
@@ -1603,7 +1603,7 @@ public:
|
||||
|
||||
virtual wxMBConv *Clone() const
|
||||
{
|
||||
wxMBConv_iconv *p = new wxMBConv_iconv(m_name);
|
||||
wxMBConv_iconv *p = new wxMBConv_iconv(m_name.ToAscii());
|
||||
p->m_minMBCharWidth = m_minMBCharWidth;
|
||||
return p;
|
||||
}
|
||||
@@ -1641,7 +1641,7 @@ private:
|
||||
};
|
||||
|
||||
// make the constructor available for unit testing
|
||||
WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
|
||||
WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name )
|
||||
{
|
||||
wxMBConv_iconv* result = new wxMBConv_iconv( name );
|
||||
if ( !result->IsOk() )
|
||||
@@ -1656,15 +1656,11 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
|
||||
wxString wxMBConv_iconv::ms_wcCharsetName;
|
||||
bool wxMBConv_iconv::ms_wcNeedsSwap = false;
|
||||
|
||||
wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
|
||||
wxMBConv_iconv::wxMBConv_iconv(const char *name)
|
||||
: m_name(name)
|
||||
{
|
||||
m_minMBCharWidth = 0;
|
||||
|
||||
// iconv operates with chars, not wxChars, but luckily it uses only ASCII
|
||||
// names for the charsets
|
||||
const wxCharBuffer cname(wxString(name).ToAscii());
|
||||
|
||||
// check for charset that represents wchar_t:
|
||||
if ( ms_wcCharsetName.empty() )
|
||||
{
|
||||
@@ -1701,13 +1697,13 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
|
||||
wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""),
|
||||
nameXE.c_str());
|
||||
|
||||
m2w = iconv_open(nameXE.ToAscii(), cname);
|
||||
m2w = iconv_open(nameXE.ToAscii(), name);
|
||||
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);
|
||||
m2w = iconv_open(nameCS.ToAscii(), name);
|
||||
|
||||
// and check for bytesex ourselves:
|
||||
if ( m2w != ICONV_T_INVALID )
|
||||
@@ -1757,7 +1753,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
|
||||
}
|
||||
else // we already have ms_wcCharsetName
|
||||
{
|
||||
m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname);
|
||||
m2w = iconv_open(ms_wcCharsetName.ToAscii(), name);
|
||||
}
|
||||
|
||||
if ( ms_wcCharsetName.empty() )
|
||||
@@ -1766,12 +1762,12 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
|
||||
}
|
||||
else
|
||||
{
|
||||
w2m = iconv_open(cname, ms_wcCharsetName.ToAscii());
|
||||
w2m = iconv_open(name, ms_wcCharsetName.ToAscii());
|
||||
if ( w2m == ICONV_T_INVALID )
|
||||
{
|
||||
wxLogTrace(TRACE_STRCONV,
|
||||
wxT("\"%s\" -> \"%s\" works but not the converse!?"),
|
||||
ms_wcCharsetName.c_str(), cname.data());
|
||||
ms_wcCharsetName.c_str(), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1982,8 +1978,8 @@ size_t wxMBConv_iconv::GetMBNulLen() const
|
||||
#if wxUSE_UNICODE_UTF8
|
||||
bool wxMBConv_iconv::IsUTF8() const
|
||||
{
|
||||
return wxStricmp(m_name, _T("UTF-8")) == 0 ||
|
||||
wxStricmp(m_name, _T("UTF8")) == 0;
|
||||
return wxStricmp(m_name, "UTF-8") == 0 ||
|
||||
wxStricmp(m_name, "UTF8") == 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1998,7 +1994,7 @@ bool wxMBConv_iconv::IsUTF8() const
|
||||
|
||||
// from utils.cpp
|
||||
#if wxUSE_FONTMAP
|
||||
extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const wxChar *charset);
|
||||
extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const char *charset);
|
||||
extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
|
||||
#endif
|
||||
|
||||
@@ -2019,7 +2015,7 @@ public:
|
||||
}
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
wxMBConv_win32(const wxChar* name)
|
||||
wxMBConv_win32(const char* name)
|
||||
{
|
||||
m_CodePage = wxCharsetToCodepage(name);
|
||||
m_minMBCharWidth = 0;
|
||||
@@ -3107,7 +3103,7 @@ private:
|
||||
public:
|
||||
// temporarily just use wxEncodingConverter stuff,
|
||||
// so that it works while a better implementation is built
|
||||
wxMBConv_wxwin(const wxChar* name)
|
||||
wxMBConv_wxwin(const char* name)
|
||||
{
|
||||
if (name)
|
||||
m_enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false);
|
||||
@@ -3180,7 +3176,7 @@ private:
|
||||
};
|
||||
|
||||
// make the constructors available for unit testing
|
||||
WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name )
|
||||
WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name )
|
||||
{
|
||||
wxMBConv_wxwin* result = new wxMBConv_wxwin( name );
|
||||
if ( !result->IsOk() )
|
||||
@@ -3205,13 +3201,13 @@ void wxCSConv::Init()
|
||||
m_deferred = true;
|
||||
}
|
||||
|
||||
wxCSConv::wxCSConv(const wxChar *charset)
|
||||
wxCSConv::wxCSConv(const wxString& charset)
|
||||
{
|
||||
Init();
|
||||
|
||||
if ( charset )
|
||||
if ( !charset.empty() )
|
||||
{
|
||||
SetName(charset);
|
||||
SetName(charset.ToAscii());
|
||||
}
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
@@ -3268,11 +3264,11 @@ void wxCSConv::Clear()
|
||||
m_convReal = NULL;
|
||||
}
|
||||
|
||||
void wxCSConv::SetName(const wxChar *charset)
|
||||
void wxCSConv::SetName(const char *charset)
|
||||
{
|
||||
if (charset)
|
||||
{
|
||||
m_name = wxStrdup(charset);
|
||||
m_name = strdup(charset);
|
||||
m_deferred = true;
|
||||
}
|
||||
}
|
||||
@@ -3291,7 +3287,7 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
wxLogTrace(TRACE_STRCONV,
|
||||
wxT("creating conversion for %s"),
|
||||
(m_name ? m_name
|
||||
: (const wxChar*)wxFontMapperBase::GetEncodingName(m_encoding).c_str()));
|
||||
: (const char*)wxFontMapperBase::GetEncodingName(m_encoding).mb_str()));
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
// check for the special case of ASCII or ISO8859-1 charset: as we have
|
||||
@@ -3318,14 +3314,13 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
if ( m_name )
|
||||
#endif // !wxUSE_FONTMAP
|
||||
{
|
||||
wxString name(m_name);
|
||||
#if wxUSE_FONTMAP
|
||||
wxFontEncoding encoding(m_encoding);
|
||||
#endif
|
||||
|
||||
if ( !name.empty() )
|
||||
if ( m_name )
|
||||
{
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(name);
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(m_name);
|
||||
if ( conv->IsOk() )
|
||||
return conv;
|
||||
|
||||
@@ -3333,7 +3328,7 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
encoding =
|
||||
wxFontMapperBase::Get()->CharsetToEncoding(name, false);
|
||||
wxFontMapperBase::Get()->CharsetToEncoding(m_name, false);
|
||||
#endif // wxUSE_FONTMAP
|
||||
}
|
||||
#if wxUSE_FONTMAP
|
||||
@@ -3344,7 +3339,7 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
if ( it->second.empty() )
|
||||
return NULL;
|
||||
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(it->second);
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(it->second.ToAscii());
|
||||
if ( conv->IsOk() )
|
||||
return conv;
|
||||
|
||||
@@ -3352,15 +3347,19 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
}
|
||||
|
||||
const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding);
|
||||
// CS : in case this does not return valid names (eg for MacRoman) encoding
|
||||
// got a 'failure' entry in the cache all the same, although it just has to
|
||||
// be created using a different method, so only store failed iconv creation
|
||||
// attempts (or perhaps we shoulnd't do this at all ?)
|
||||
// CS : in case this does not return valid names (eg for MacRoman)
|
||||
// encoding got a 'failure' entry in the cache all the same,
|
||||
// although it just has to be created using a different method, so
|
||||
// only store failed iconv creation attempts (or perhaps we
|
||||
// shoulnd't do this at all ?)
|
||||
if ( names[0] != NULL )
|
||||
{
|
||||
for ( ; *names; ++names )
|
||||
{
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(*names);
|
||||
// FIXME-UTF8: wxFontMapperBase::GetAllEncodingNames()
|
||||
// will need changes that will obsolete this
|
||||
wxString name(*names);
|
||||
wxMBConv_iconv *conv = new wxMBConv_iconv(name.ToAscii());
|
||||
if ( conv->IsOk() )
|
||||
{
|
||||
gs_nameCache[encoding] = *names;
|
||||
@@ -3494,9 +3493,9 @@ wxMBConv *wxCSConv::DoCreate() const
|
||||
m_name ? m_name
|
||||
:
|
||||
#if wxUSE_FONTMAP
|
||||
(const wxChar*)wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
|
||||
(const char*)wxFontMapperBase::GetEncodingDescription(m_encoding).ToAscii()
|
||||
#else // !wxUSE_FONTMAP
|
||||
(const wxChar*)wxString::Format(_("encoding %i"), m_encoding).c_str()
|
||||
(const char*)wxString::Format(_("encoding %i"), m_encoding).ToAscii()
|
||||
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user