#if wxUSE_WCHAR_T
size_t WXDLLEXPORT wxMB2WC(wchar_t *buf, const char *psz, size_t n)
{
+ // assume that we have mbsrtowcs() too if we have wcsrtombs()
+#if HAVE_WCSRTOMBS
+ mbstate_t mbstate;
+ memset(&mbstate, 0, sizeof(mbstate_t));
+#endif
+
if (buf) {
if (!n || !*psz) {
if (n) *buf = wxT('\0');
return 0;
}
+#ifdef HAVE_WCSRTOMBS
+ return mbsrtowcs(buf, &psz, n, &mbstate);
+#else
return mbstowcs(buf, psz, n);
+#endif
}
- // assume that we have mbsrtowcs() too if we have wcsrtombs()
#ifdef HAVE_WCSRTOMBS
- mbstate_t mbstate;
return mbsrtowcs((wchar_t *) NULL, &psz, 0, &mbstate);
-#else // !GNU libc
+#else
return mbstowcs((wchar_t *) NULL, psz, 0);
-#endif // GNU
+#endif
}
size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *pwz, size_t n)
{
+#if HAVE_WCSRTOMBS
+ mbstate_t mbstate;
+ memset(&mbstate, 0, sizeof(mbstate_t));
+#endif
+
if (buf) {
if (!n || !*pwz) {
// glibc2.1 chokes on null input
if (n) *buf = '\0';
return 0;
}
+#if HAVE_WCSRTOMBS
+ return wcsrtombs(buf, &pwz, n, &mbstate);
+#else
return wcstombs(buf, pwz, n);
+#endif
}
#if HAVE_WCSRTOMBS
- mbstate_t mbstate;
return wcsrtombs((char *) NULL, &pwz, 0, &mbstate);
-#else // !GNU libc
+#else
return wcstombs((char *) NULL, pwz, 0);
-#endif // GNU
+#endif
}
#endif // wxUSE_WCHAR_T
WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); }
#endif
-#ifndef wxStrdup
-WXDLLEXPORT wxChar * wxStrdup(const wxChar *psz)
+#ifndef wxStrdupA
+
+WXDLLEXPORT char *wxStrdupA(const char *s)
{
- size_t size = (wxStrlen(psz) + 1) * sizeof(wxChar);
- wxChar *ret = (wxChar *) malloc(size);
- memcpy(ret, psz, size);
+ return strcpy((char *)malloc(strlen(s) + 1), s);
+}
+
+#endif // wxStrdupA
+
+#ifndef wxStrdupW
+
+WXDLLEXPORT wchar_t * wxStrdupW(const wchar_t *pwz)
+{
+ size_t size = (wxWcslen(pwz) + 1) * sizeof(wchar_t);
+ wchar_t *ret = (wchar_t *) malloc(size);
+ memcpy(ret, pwz, size);
return ret;
}
-#endif
+
+#endif // wxStrdupW
#ifndef wxStricmp
int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2)