+ // try charset with explicit bytesex info (e.g. "UCS-4LE"):
+ g_wcCharset = WC_NAME_BEST;
+ m2w = iconv_open(g_wcCharset, wxConvLibc.cWX2MB(name));
+
+ if (m2w == (iconv_t)-1)
+ {
+ // try charset w/o bytesex info (e.g. "UCS4")
+ // and check for bytesex ourselves:
+ g_wcCharset = WC_NAME;
+ m2w = iconv_open(g_wcCharset, wxConvLibc.cWX2MB(name));
+
+ // last bet, try if it knows WCHAR_T pseudo-charset
+ if (m2w == (iconv_t)-1)
+ {
+ g_wcCharset = "WCHAR_T";
+ m2w = iconv_open(g_wcCharset, wxConvLibc.cWX2MB(name));
+ }
+
+ if (m2w != (iconv_t)-1)
+ {
+ char buf[2], *bufPtr;
+ wchar_t wbuf[2], *wbufPtr;
+ size_t insz, outsz;
+ size_t res;
+
+ buf[0] = 'A';
+ buf[1] = 0;
+ wbuf[0] = 0;
+ insz = 2;
+ outsz = SIZEOF_WCHAR_T * 2;
+ wbufPtr = wbuf;
+ bufPtr = buf;
+
+ #ifdef WX_ICONV_TAKES_CHAR
+ res = iconv(m2w, (char**)&bufPtr, &insz, (char**)&wbufPtr, &outsz);
+ #else
+ res = iconv(m2w, (const char**)&bufPtr, &insz, (char**)&wbufPtr, &outsz);
+ #endif
+ if (ICONV_FAILED(res, insz))
+ {
+ g_wcCharset = NULL;
+ wxLogLastError(wxT("iconv"));
+ wxLogError(_("Convertion to charset '%s' doesn't work."), name);
+ }
+ else
+ {
+ g_wcNeedsSwap = (wbuf[0] != (wchar_t)buf[0]);
+ }
+ }
+ else
+ {
+ g_wcCharset = NULL;
+ wxLogError(_("Don't know how to convert to/from charset '%s'."), name);
+ }
+ }
+ wxLogTrace(wxT("strconv"), wxT("wchar_t charset is '%s', needs swap: %i"), g_wcCharset, g_wcNeedsSwap);
+ }
+ else
+ m2w = iconv_open(g_wcCharset, wxConvLibc.cWX2MB(name));
+
+ w2m = iconv_open(wxConvLibc.cWX2MB(name), g_wcCharset);
+ }
+
+ ~IC_CharSet()