#include <xlocale.h>
#endif
-#if wxUSE_WCHAR_T
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n)
{
// assume that we have mbsrtowcs() too if we have wcsrtombs()
return wxWcstombs(NULL, pwz, 0);
#endif
}
-#endif // wxUSE_WCHAR_T
char* wxSetlocale(int category, const char *locale)
{
#if !wxUSE_UTF8_LOCALE_ONLY
int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
{
- const wxWX2WCbuf buf = s.wc_str();
+ const wxCharBuffer buf(s.mb_str());
- size_t len = wxConvLibc.FromWChar(out, outsize, buf);
- if ( len != wxCONV_FAILED )
- return len-1;
- else
- return wxConvLibc.FromWChar(NULL, 0, buf);
+ const size_t len = buf.length();
+ if ( outsize > len )
+ {
+ memcpy(out, buf, (len+1) * sizeof(char));
+ }
+ else // not enough space
+ {
+ memcpy(out, buf, (outsize-1) * sizeof(char));
+ out[outsize-1] = '\0';
+ }
+
+ return len;
}
#endif // !wxUSE_UTF8_LOCALE_ONLY
}
#endif // wxUSE_UNICODE
-#if wxUSE_WCHAR_T
// ----------------------------------------------------------------------------
// ctype.h stuff (currently unused)
}
#endif // !wxCRT_StrftimeW
-#endif // wxUSE_WCHAR_T
-
#ifdef wxLongLong_t
template<typename T>
static wxULongLong_t
#endif // wxLongLong_t
// ----------------------------------------------------------------------------
-// functions which we may need even if !wxUSE_WCHAR_T
+// strtok() functions
// ----------------------------------------------------------------------------
template<typename T>