#error "MBCS is not supported by wxChar"
#endif
-// only do Unicode for Windows (VC++), for now
+// Windows (VC++) has broad TCHAR support
#if defined(__VISUALC__) && defined(__WIN32__)
#include <tchar.h>
// translate wxZZZ names
-#else//!Unicode
+#else//!Windows (VC++)
+
+// check whether we are doing Unicode
+#if wxUSE_UNICODE
+
+#include <wchar.h>
+#include <wctype.h>
+
+// this is probably glibc-specific
+#if defined(__WCHAR_TYPE__)
+
+typedef __WCHAR_TYPE__ wxChar;
+typedef signed __WCHAR_TYPE__ wxSChar;
+typedef unsigned __WCHAR_TYPE__ wxUChar;
+
+#define _T(x) L##x
+
+ // ctype.h functions (wctype.h)
+#define wxIsalnum iswalnum
+#define wxIsalpha iswalpha
+#define wxIsctrl iswcntrl
+#define wxIsdigit iswdigit
+#define wxIsgraph iswgraph
+#define wxIslower iswlower
+#define wxIsprint iswprint
+#define wxIspunct iswpunct
+#define wxIsspace iswspace
+#define wxIsupper iswupper
+#define wxIsxdigit iswxdigit
+#define wxTolower towlower
+#define wxToupper towupper
+
+ // string.h functions (wchar.h)
+#define wxStrcat wcscat
+#define wxStrchr wcschr
+#define wxStrcmp wcscmp
+#define wxStrcoll wcscoll
+#define wxStrcpy wcscpy
+#define wxStrcspn wcscspn
+#define wxStrncat wcsncat
+#define wxStrncmp wcsncmp
+#define wxStrncpy wcsncpy
+#define wxStrpbrk wcspbrk
+#define wxStrrchr wcsrchr
+#define wxStrspn wcsspn
+#define wxStrstr wcsstr
+#define wxStrtod wcstod
+#define wxStrtok wcstok
+#define wxStrtol wcstol
+#define wxStrtoul wcstoul
+#define wxStrxfrm wcsxfrm
-// make sure we aren't doing Unicode
-#if defined ( __WXUNICODE__ ) || defined ( _UNICODE )
+// glibc doesn't have wc equivalents of the other stuff
+// do we need to write wrappers for them?
+
+#else
#error "Please define your compiler's Unicode conventions in wxChar.h"
#endif
+#else//!Unicode
typedef char wxChar;
typedef signed char wxSChar;
#define wxStrcoll strcoll
#define wxStrcpy strcpy
#define wxStrcspn strcspn
-#define wxStrftime strftime
#define wxStrncat strncat
#define wxStrncmp strncmp
#define wxStrncpy strncpy
// time.h functions
#define wxAsctime asctime
#define wxCtime ctime
+#define wxStrftime strftime
#endif//Unicode
+#endif
/// checks whether the passed in pointer is NULL and if the string is empty
inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz)
#if defined(__VISUALC__)
{ return psz ? _tcslen(psz) : 0; }
+#elif wxUSE_UNICODE
+ { return psz ? wcslen(psz) : 0; }
#else
{ return psz ? strlen(psz) : 0; }
#endif
/// portable strcasecmp/_stricmp
-inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *)
+inline int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2)
#if defined(__VISUALC__)
{ return _tcsicmp(psz1, psz2); }
-#elif defined(__BORLANDC__)
+#elif defined(__BORLANDC__) && !wxUSE_UNICODE
{ return stricmp(psz1, psz2); }
-#elif defined(__UNIX__) || defined(__GNUWIN32__)
+#elif defined(__UNIX__) || defined(__GNUWIN32__)
+#if !wxUSE_UNICODE
{ return strcasecmp(psz1, psz2); }
+#else // glibc doesn't seem to have wide char equivalent
+ {
+ register wxChar c1, c2;
+ do {
+ c1 = wxTolower(*psz1++);
+ c2 = wxTolower(*psz2++);
+ } while ( c1 && (c1 == c2) );
+
+ return c1 - c2;
+ }
+#endif
#else
// almost all compilers/libraries provide this function (unfortunately under
// different names), that's why we don't implement our own which will surely
// be more efficient than this code (uncomment to use):
/*
- register char c1, c2;
+ register wxChar c1, c2;
do {
- c1 = tolower(*psz1++);
- c2 = tolower(*psz2++);
+ c1 = wxTolower(*psz1++);
+ c2 = wxTolower(*psz2++);
} while ( c1 && (c1 == c2) );
return c1 - c2;