Unicode definitions for glibc, etc.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2075 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven
1999-04-08 23:38:47 +00:00
parent 64ef36223c
commit 34f9227c5a

View File

@@ -21,7 +21,7 @@
#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>
@@ -113,12 +113,65 @@ typedef _TUCHAR wxUChar;
// translate wxZZZ names
#else//!Unicode
#else//!Windows (VC++)
// make sure we aren't doing Unicode
#if defined ( __WXUNICODE__ ) || defined ( _UNICODE )
// 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
// 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;
@@ -151,7 +204,6 @@ typedef unsigned char wxUChar;
#define wxStrcoll strcoll
#define wxStrcpy strcpy
#define wxStrcspn strcspn
#define wxStrftime strftime
#define wxStrncat strncat
#define wxStrncmp strncmp
#define wxStrncpy strncpy
@@ -203,8 +255,10 @@ typedef unsigned char wxUChar;
// 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
@@ -214,27 +268,41 @@ inline bool WXDLLEXPORT wxIsEmpty(const wxChar *p) { return !p || !*p; }
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;