X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34f9227c5a7ffde70ef48da7268821082a866134..d4ffe273ca70deb8e2cff7be9a07b0640e24bee0:/include/wx/wxchar.h diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index c5b0529e99..5832ca016c 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -25,9 +25,15 @@ #if defined(__VISUALC__) && defined(__WIN32__) #include +#if wxUSE_UNICODE // temporary - preserve binary compatibility typedef _TCHAR wxChar; typedef _TSCHAR wxSChar; typedef _TUCHAR wxUChar; +#else +#define wxChar char +#define wxSChar signed char +#define wxUChar unsigned char +#endif // ctype.h functions #define wxIsalnum _istalnum @@ -63,7 +69,7 @@ typedef _TUCHAR wxUChar; #define wxStrspn _tcsspn #define wxStrstr _tcsstr #define wxStrtod _tcstod -#define wxStrtok _tcstok +// is there a _tcstok[_r] ? #define wxStrtol _tcstol #define wxStrtoul _tcstoul #define wxStrxfrm _tcsxfrm @@ -95,9 +101,13 @@ typedef _TUCHAR wxUChar; #define wxUngetc _tungetc #define wxVfprint _vftprintf #define wxVprintf _vtprintf +#define wxVsscanf _vstscanf #define wxVsprintf _vstprintf // stdlib.h functions +#if !wxUSE_UNICODE +#define wxAtof atof +#endif #define wxAtoi _ttoi #define wxAtol _ttol #define wxGetenv _tgetenv @@ -142,8 +152,16 @@ typedef unsigned __WCHAR_TYPE__ wxUChar; #define wxIsspace iswspace #define wxIsupper iswupper #define wxIsxdigit iswxdigit -#define wxTolower towlower -#define wxToupper towupper + +#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) + // /usr/include/wctype.h incorrectly declares translations tables which + // provokes tons of compile-time warnings - try to correct this + #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower) + #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper) +#else + #define wxTolower towlower + #define wxToupper towupper +#endif // gcc/!gcc // string.h functions (wchar.h) #define wxStrcat wcscat @@ -166,16 +184,27 @@ typedef unsigned __WCHAR_TYPE__ wxUChar; #define wxStrxfrm wcsxfrm // glibc doesn't have wc equivalents of the other stuff -// do we need to write wrappers for them? +#define wxNEED_WX_STDIO_H +#define wxNEED_WX_STDLIB_H +#define wxNEED_WX_TIME_H #else #error "Please define your compiler's Unicode conventions in wxChar.h" #endif #else//!Unicode +#include +#include + +#if 0 // temporary - preserve binary compatibilty typedef char wxChar; typedef signed char wxSChar; typedef unsigned char wxUChar; +#else +#define wxChar char +#define wxSChar signed char +#define wxUChar unsigned char +#endif #define _T(x) x @@ -204,6 +233,7 @@ typedef unsigned char wxUChar; #define wxStrcoll strcoll #define wxStrcpy strcpy #define wxStrcspn strcspn +#define wxStrdup strdup #define wxStrncat strncat #define wxStrncmp strncmp #define wxStrncpy strncpy @@ -212,7 +242,7 @@ typedef unsigned char wxUChar; #define wxStrspn strspn #define wxStrstr strstr #define wxStrtod strtod -#define wxStrtok strtok +// #define wxStrtok strtok_r // this needs a configure check #define wxStrtol strtol #define wxStrtoul strtoul #define wxStrxfrm strxfrm @@ -244,9 +274,11 @@ typedef unsigned char wxUChar; #define wxUngetc ungetc #define wxVfprint vfprintf #define wxVprintf vprintf +#define wxVsscanf vsscanf #define wxVsprintf vsprintf // stdlib.h functions +#define wxAtof atof #define wxAtoi atoi #define wxAtol atol #define wxGetenv getenv @@ -265,7 +297,7 @@ typedef unsigned char wxUChar; inline bool WXDLLEXPORT wxIsEmpty(const wxChar *p) { return !p || !*p; } /// safe version of strlen() (returns 0 if passed NULL pointer) -inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) +inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) #if defined(__VISUALC__) { return psz ? _tcslen(psz) : 0; } #elif wxUSE_UNICODE @@ -311,5 +343,57 @@ inline int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2) #error "Please define string case-insensitive compare for your OS/compiler" #endif // OS/compiler +// multibyte<->widechar conversion +size_t WXDLLEXPORT wxMB2WC(wchar_t *buf, const char *psz, size_t n); +size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *psz, size_t n); +#if wxUSE_UNICODE +#define wxMB2WX wxMB2WC +#define wxWX2MB wxWC2MB +#define wxWC2WX wxStrncpy +#define wxWX2WC wxStrncpy +#else +#define wxMB2WX wxStrncpy +#define wxWX2MB wxStrncpy +#define wxWC2WX wxWC2MB +#define wxWX2WC wxMB2WC +#endif + +// if libc versions are not available, use replacements defined in wxchar.cpp +#ifndef wxStrdup +wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz); +#endif + +#ifndef wxStrtok +wxChar * WXDLLEXPORT wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr); +#endif + +#ifndef wxSetlocale +wxChar * WXDLLEXPORT wxSetlocale(int category, const wxChar *locale); +#endif + +#ifdef wxNEED_WX_STDIO_H +#include +#include +int WXDLLEXPORT wxPrintf(const wxChar *fmt, ...); +int WXDLLEXPORT wxVprintf(const wxChar *fmt, va_list argptr); +int WXDLLEXPORT wxFprintf(FILE *stream, const wxChar *fmt, ...); +int WXDLLEXPORT wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr); +int WXDLLEXPORT wxSprintf(wxChar *buf, const wxChar *fmt, ...); +int WXDLLEXPORT wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr); +int WXDLLEXPORT wxSscanf(const wxChar *buf, const wxChar *fmt, ...); +int WXDLLEXPORT wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr); +#endif + +#ifndef wxAtof +double WXDLLEXPORT wxAtof(const wxChar *psz); +#endif + +#ifdef wxNEED_WX_STDLIB_H +int WXDLLEXPORT wxAtoi(const wxChar *psz); +long WXDLLEXPORT wxAtol(const wxChar *psz); +wxChar * WXDLLEXPORT wxGetenv(const wxChar *name); +int WXDLLEXPORT wxSystem(const wxChar *psz); +#endif + #endif //_WX_WXCHAR_H_