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:
@@ -21,7 +21,7 @@
|
|||||||
#error "MBCS is not supported by wxChar"
|
#error "MBCS is not supported by wxChar"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// only do Unicode for Windows (VC++), for now
|
// Windows (VC++) has broad TCHAR support
|
||||||
#if defined(__VISUALC__) && defined(__WIN32__)
|
#if defined(__VISUALC__) && defined(__WIN32__)
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
@@ -113,12 +113,65 @@ typedef _TUCHAR wxUChar;
|
|||||||
|
|
||||||
// translate wxZZZ names
|
// translate wxZZZ names
|
||||||
|
|
||||||
#else//!Unicode
|
#else//!Windows (VC++)
|
||||||
|
|
||||||
// make sure we aren't doing Unicode
|
// check whether we are doing Unicode
|
||||||
#if defined ( __WXUNICODE__ ) || defined ( _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"
|
#error "Please define your compiler's Unicode conventions in wxChar.h"
|
||||||
#endif
|
#endif
|
||||||
|
#else//!Unicode
|
||||||
|
|
||||||
typedef char wxChar;
|
typedef char wxChar;
|
||||||
typedef signed char wxSChar;
|
typedef signed char wxSChar;
|
||||||
@@ -151,7 +204,6 @@ typedef unsigned char wxUChar;
|
|||||||
#define wxStrcoll strcoll
|
#define wxStrcoll strcoll
|
||||||
#define wxStrcpy strcpy
|
#define wxStrcpy strcpy
|
||||||
#define wxStrcspn strcspn
|
#define wxStrcspn strcspn
|
||||||
#define wxStrftime strftime
|
|
||||||
#define wxStrncat strncat
|
#define wxStrncat strncat
|
||||||
#define wxStrncmp strncmp
|
#define wxStrncmp strncmp
|
||||||
#define wxStrncpy strncpy
|
#define wxStrncpy strncpy
|
||||||
@@ -203,8 +255,10 @@ typedef unsigned char wxUChar;
|
|||||||
// time.h functions
|
// time.h functions
|
||||||
#define wxAsctime asctime
|
#define wxAsctime asctime
|
||||||
#define wxCtime ctime
|
#define wxCtime ctime
|
||||||
|
#define wxStrftime strftime
|
||||||
|
|
||||||
#endif//Unicode
|
#endif//Unicode
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// checks whether the passed in pointer is NULL and if the string is empty
|
/// 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)
|
inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz)
|
||||||
#if defined(__VISUALC__)
|
#if defined(__VISUALC__)
|
||||||
{ return psz ? _tcslen(psz) : 0; }
|
{ return psz ? _tcslen(psz) : 0; }
|
||||||
|
#elif wxUSE_UNICODE
|
||||||
|
{ return psz ? wcslen(psz) : 0; }
|
||||||
#else
|
#else
|
||||||
{ return psz ? strlen(psz) : 0; }
|
{ return psz ? strlen(psz) : 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// portable strcasecmp/_stricmp
|
/// portable strcasecmp/_stricmp
|
||||||
inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *)
|
inline int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2)
|
||||||
#if defined(__VISUALC__)
|
#if defined(__VISUALC__)
|
||||||
{ return _tcsicmp(psz1, psz2); }
|
{ return _tcsicmp(psz1, psz2); }
|
||||||
#elif defined(__BORLANDC__)
|
#elif defined(__BORLANDC__) && !wxUSE_UNICODE
|
||||||
{ return stricmp(psz1, psz2); }
|
{ return stricmp(psz1, psz2); }
|
||||||
#elif defined(__UNIX__) || defined(__GNUWIN32__)
|
#elif defined(__UNIX__) || defined(__GNUWIN32__)
|
||||||
|
#if !wxUSE_UNICODE
|
||||||
{ return strcasecmp(psz1, psz2); }
|
{ 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
|
#else
|
||||||
// almost all compilers/libraries provide this function (unfortunately under
|
// almost all compilers/libraries provide this function (unfortunately under
|
||||||
// different names), that's why we don't implement our own which will surely
|
// different names), that's why we don't implement our own which will surely
|
||||||
// be more efficient than this code (uncomment to use):
|
// be more efficient than this code (uncomment to use):
|
||||||
/*
|
/*
|
||||||
register char c1, c2;
|
register wxChar c1, c2;
|
||||||
do {
|
do {
|
||||||
c1 = tolower(*psz1++);
|
c1 = wxTolower(*psz1++);
|
||||||
c2 = tolower(*psz2++);
|
c2 = wxTolower(*psz2++);
|
||||||
} while ( c1 && (c1 == c2) );
|
} while ( c1 && (c1 == c2) );
|
||||||
|
|
||||||
return c1 - c2;
|
return c1 - c2;
|
||||||
|
Reference in New Issue
Block a user