#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);
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;
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;
}
};
// 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() )
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() )
{
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 )
wxLogTrace(TRACE_STRCONV,
wxT("iconv wchar_t charset is \"%s\"%s"),
- ms_wcCharsetName.empty() ? _T("<none>")
- : ms_wcCharsetName.c_str(),
+ ms_wcCharsetName.empty() ? wxString("<none>")
+ : ms_wcCharsetName,
ms_wcNeedsSwap ? _T(" (needs swap)")
: _T(""));
}
else // we already have ms_wcCharsetName
{
- m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname);
+ m2w = iconv_open(ms_wcCharsetName.ToAscii(), name);
}
if ( ms_wcCharsetName.empty() )
}
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);
}
}
}
wxMutexLocker lock(self->m_iconvMutex);
#endif
- wchar_t *wnul = L"";
+ const wchar_t *wnul = L"";
char buf[8]; // should be enough for NUL in any encoding
size_t inLen = sizeof(wchar_t),
outLen = WXSIZEOF(buf);
// 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
}
#if wxUSE_FONTMAP
- wxMBConv_win32(const wxChar* name)
+ wxMBConv_win32(const char* name)
{
m_CodePage = wxCharsetToCodepage(name);
m_minMBCharWidth = 0;
}
#if wxUSE_FONTMAP
- wxMBConv_mac(const wxChar* name)
+ wxMBConv_mac(const char* name)
{
Init( wxMacGetSystemEncFromFontEnc( wxFontMapperBase::Get()->CharsetToEncoding(name, false) ) );
}
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);
};
// 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() )
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
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;
}
}
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
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;
#if wxUSE_FONTMAP
encoding =
- wxFontMapperBase::Get()->CharsetToEncoding(name, false);
+ wxFontMapperBase::Get()->CharsetToEncoding(m_name, false);
#endif // wxUSE_FONTMAP
}
#if wxUSE_FONTMAP
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;
}
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;
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
);