// Created: 09/04/99
// RCS-ID: $Id$
// Copyright: (c) wxWindows copyright
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <winnt.h>
#endif
+#if defined(__MWERKS__) && __MSL__ >= 0x6000
+using namespace std ;
+#endif
+
#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
bool WXDLLEXPORT wxOKlibc()
{
-#if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__)
+#if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__) && !defined(__WINE__)
// glibc 2.0 uses UTF-8 even when it shouldn't
wchar_t res = 0;
if ((MB_CUR_MAX == 2) &&
{
va_list argptr;
va_start(argptr, format);
-
int ret = vfwscanf(stream, wxFormatConverter(format), argptr);
va_end(argptr);
#endif // wxNEED_PRINTF_CONVERSION
+#if wxUSE_WCHAR_T
+
// ----------------------------------------------------------------------------
// ctype.h stuff (currently unused)
// ----------------------------------------------------------------------------
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)
}
#endif
-#ifndef wxStrtok
-WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr)
-{
- if (!psz)
- {
- psz = *save_ptr;
- if ( !psz )
- return NULL;
- }
-
- psz += wxStrspn(psz, delim);
- if (!*psz)
- {
- *save_ptr = (wxChar *)NULL;
- return (wxChar *)NULL;
- }
-
- wxChar *ret = psz;
- psz = wxStrpbrk(psz, delim);
- if (!psz)
- {
- *save_ptr = (wxChar*)NULL;
- }
- else
- {
- *psz = wxT('\0');
- *save_ptr = psz + 1;
- }
-
- return ret;
-}
-#endif // wxStrtok
-
#ifndef wxSetlocale
WXDLLEXPORT wxWCharBuffer wxSetlocale(int category, const wxChar *locale)
{
return system(wxConvLocal.cWX2MB(psz));
}
-#endif
+#endif // wxNEED_WX_STDLIB_H
#ifdef wxNEED_WX_TIME_H
WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm)
return 0;
}
}
-#endif
+#endif // wxNEED_WX_TIME_H
+
+#endif // wxUSE_WCHAR_T
+
+// ----------------------------------------------------------------------------
+// functions which we may need even if !wxUSE_WCHAR_T
+// ----------------------------------------------------------------------------
+
+#ifndef wxStrtok
+
+WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr)
+{
+ if (!psz)
+ {
+ psz = *save_ptr;
+ if ( !psz )
+ return NULL;
+ }
+
+ psz += wxStrspn(psz, delim);
+ if (!*psz)
+ {
+ *save_ptr = (wxChar *)NULL;
+ return (wxChar *)NULL;
+ }
+
+ wxChar *ret = psz;
+ psz = wxStrpbrk(psz, delim);
+ if (!psz)
+ {
+ *save_ptr = (wxChar*)NULL;
+ }
+ else
+ {
+ *psz = wxT('\0');
+ *save_ptr = psz + 1;
+ }
+
+ return ret;
+}
+
+#endif // wxStrtok
+