-/**
-* Name: wx/wxchar.h
-* Purpose: Declarations common to wx char/wchar_t usage (wide chars)
-* Author: Joel Farley, Ove Kåven
-* Modified by: Vadim Zeitlin, Robert Roebling
-* Created: 1998/06/12
-* RCS-ID: $Id$
-* Copyright: (c) 1998-2002 wxWindows dev team
-* Licence: wxWindows licence
-*/
+/*
+ * Name: wx/wxchar.h
+ * Purpose: Declarations common to wx char/wchar_t usage (wide chars)
+ * Author: Joel Farley, Ove Kåven
+ * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
+ * Created: 1998/06/12
+ * RCS-ID: $Id$
+ * Copyright: (c) 1998-2002 wxWindows dev team
+ * Licence: wxWindows licence
+ */
-#include "wx/defs.h" /* for wxUSE_UNICODE */
-
-/* ---------------------------------------------------------------------------- */
-/* check whether we have wchar_t and which size it is if we do */
-/* ---------------------------------------------------------------------------- */
+#include "wx/defs.h" /* for wxUSE_UNICODE */
-/* ---------------------------------------------------------------------------- */
-/* standard headers we need here */
-/* */
-/* NB: don't include any wxWindows headers here because almost of them include */
-/* this one! */
-/* ---------------------------------------------------------------------------- */
+/*
+ Standard headers we need here.
-/* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
-/* and VC++ for Windows CE don't provide it */
+/* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
+/* and VC++ for Windows CE don't provide it */
-/* non Unix compilers which do have wchar.h (but not tchar.h which is included */
-/* below and which includes wchar.h anyhow). */
-/* Actually MinGW has tchar.h, but it does not include wchar.h */
+/*
+ non Unix compilers which do have wchar.h (but not tchar.h which is included
+ below and which includes wchar.h anyhow).
+
+ Actually MinGW has tchar.h, but it does not include wchar.h
+ */
- /* the current (as of Nov 2002) version of cygwin has a bug in its */
- /* wchar.h -- there is no extern "C" around the declarations in it and */
- /* this results in linking errors later; also, at least on some */
- /* Cygwin versions, wchar.h requires sys/types.h */
+ /* the current (as of Nov 2002) version of cygwin has a bug in its */
+ /* wchar.h -- there is no extern "C" around the declarations in it and */
+ /* this results in linking errors later; also, at least on some */
+ /* Cygwin versions, wchar.h requires sys/types.h */
-/* ---------------------------------------------------------------------------- */
-/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
-/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
-/* the function mapping _tfoo() -> foo() or wfoo() */
-/* ---------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------- */
+/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
+/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
+/* the function mapping _tfoo() -> foo() or wfoo() */
+/* ---------------------------------------------------------------------------- */
#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
#define wxHAVE_TCHAR_SUPPORT
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
#define wxHAVE_TCHAR_SUPPORT
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
- /* VZ: the old VisualAge definitions were completely wrong and had no */
- /* chance at all to work in Unicode build anyhow so let's pretend that */
- /* VisualAge does _not_ support TCHAR for the moment (as indicated by */
- /* "0 &&" above) until someone really has time to delve into Unicode */
- /* issues under OS/2 */
+ /* VZ: the old VisualAge definitions were completely wrong and had no */
+ /* chance at all to work in Unicode build anyhow so let's pretend that */
+ /* VisualAge does _not_ support TCHAR for the moment (as indicated by */
+ /* "0 &&" above) until someone really has time to delve into Unicode */
+ /* issues under OS/2 */
-/* ---------------------------------------------------------------------------- */
-/* define wxChar type */
-/* ---------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------- */
+/* define wxChar type */
+/* ---------------------------------------------------------------------------- */
-#else /* Unicode */
- /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
- /* signed/unsigned version of it which (a) makes sense to me (unlike */
- /* char wchar_t is always unsigned) and (b) was how the previous */
- /* definitions worked so keep it like this */
-
- /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
- /* comment below */
+#else /* Unicode */
+ /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
+ /* signed/unsigned version of it which (a) makes sense to me (unlike */
+ /* char wchar_t is always unsigned) and (b) was how the previous */
+ /* definitions worked so keep it like this */
+
+ /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
+ /* comment below */
#if !defined(__WCHAR_TYPE__) || \
(!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
#if !defined(__WCHAR_TYPE__) || \
(!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
- #else /* __WCHAR_TYPE__ and gcc < 2.96 */
- /* VS: wxWindows used to define wxChar as __WCHAR_TYPE__ here. However, */
- /* this doesn't work with new GCC 3.x compilers because wchar_t is */
- /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */
- /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */
- /* have to define wxChar conditionally depending on detected */
- /* compiler & compiler version. */
- /* with old definition of wxChar. */
+ #else /* __WCHAR_TYPE__ and gcc < 2.96 */
+ /* VS: wxWindows used to define wxChar as __WCHAR_TYPE__ here. However, */
+ /* this doesn't work with new GCC 3.x compilers because wchar_t is */
+ /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */
+ /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */
+ /* have to define wxChar conditionally depending on detected */
+ /* compiler & compiler version. */
+ /* with old definition of wxChar. */
typedef __WCHAR_TYPE__ wxChar;
typedef __WCHAR_TYPE__ wxSChar;
typedef __WCHAR_TYPE__ wxUChar;
typedef __WCHAR_TYPE__ wxChar;
typedef __WCHAR_TYPE__ wxSChar;
typedef __WCHAR_TYPE__ wxUChar;
-/* ---------------------------------------------------------------------------- */
-/* define _T() and related macros */
-/* ---------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------- */
+/* define _T() and related macros */
+/* ---------------------------------------------------------------------------- */
-/* although global macros with such names are normally bad, we want to have */
-/* another name for _T() which should be used to avoid confusion between _T() */
-/* and _() in wxWindows sources */
+/* although global macros with such names are normally bad, we want to have */
+/* another name for _T() which should be used to avoid confusion between _T() */
+/* and _() in wxWindows sources */
-/* ---------------------------------------------------------------------------- */
-/* define wxFoo() function for each standard foo() function whose signature */
-/* (exceptionally including the return type) includes any mention of char: */
-/* wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have */
-/* the same signature but with char replaced by wxChar which allows us to use */
-/* it in Unicode build as well */
-/* ---------------------------------------------------------------------------- */
+/*
+ define wxFoo() function for each standard foo() function whose signature
+ (exceptionally including the return type) includes any mention of char:
+ wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
+ the same signature but with char replaced by wxChar which allows us to use
+ it in Unicode build as well
+ */
#define wxIsdigit _istdigit
#define wxIsgraph _istgraph
#define wxIslower _istlower
#define wxIsdigit _istdigit
#define wxIsgraph _istgraph
#define wxIslower _istlower
#define wxStrftime _tcsftime
#define wxStricmp _tcsicmp
#define wxStrnicmp _tcsnicmp
#define wxStrftime _tcsftime
#define wxStricmp _tcsicmp
#define wxStrnicmp _tcsnicmp
#define wxStrncat _tcsncat
#define wxStrncmp _tcsncmp
#define wxStrncpy _tcsncpy
#define wxStrncat _tcsncat
#define wxStrncmp _tcsncmp
#define wxStrncpy _tcsncpy
- #define wxSprintf _stprintf
+ #if defined(__DMC__)
+ #if wxUSE_UNICODE
+ /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
+ int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
+ #else
+ /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
+ #define wxSprintf sprintf
+ #endif
+ #else
+ #define wxSprintf _stprintf
+ #endif
+
#define wxSscanf _stscanf
#define wxTmpnam _ttmpnam
#define wxUngetc _tungetc
#define wxSscanf _stscanf
#define wxTmpnam _ttmpnam
#define wxUngetc _tungetc
#if defined(__VISUALC__) || \
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
#define wxVsnprintf_ _vsntprintf
#define wxSnprintf_ _sntprintf
#endif
#if defined(__VISUALC__) || \
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
#define wxVsnprintf_ _vsntprintf
#define wxSnprintf_ _sntprintf
#endif
- /* special case: these functions are missing under Win9x with Unicows so we */
- /* have to implement them ourselves */
+ /* special case: these functions are missing under Win9x with Unicows so we */
+ /* have to implement them ourselves */
- /* this is probably glibc-specific */
- #if defined(__WCHAR_TYPE__)
- /* ctype.h functions (wctype.h) */
+ /* this is probably glibc-specific */
+ #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
+ /* ctype.h functions (wctype.h) */
#define wxIsdigit iswdigit
#define wxIsgraph iswgraph
#define wxIslower iswlower
#define wxIsdigit iswdigit
#define wxIsgraph iswgraph
#define wxIslower iswlower
- /* /usr/include/wctype.h incorrectly declares translations */
- /* tables which provokes tons of compile-time warnings -- try */
- /* to correct this */
+ /* /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)
#define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
#define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
#define wxStrncat wcsncat
#define wxStrncmp wcsncmp
#define wxStrncpy wcsncpy
#define wxStrncat wcsncat
#define wxStrncmp wcsncmp
#define wxStrncpy wcsncpy
#define wxNEED_WX_STDIO_H
#define wxNEED_WX_STDLIB_H
#define wxNEED_WX_TIME_H
#elif defined(__MWERKS__) && ( defined(macintosh) || defined(__MACH__) )
#define wxNEED_WX_STDIO_H
#define wxNEED_WX_STDLIB_H
#define wxNEED_WX_TIME_H
#elif defined(__MWERKS__) && ( defined(macintosh) || defined(__MACH__) )
#define wxIsdigit iswdigit
#define wxIsgraph iswgraph
#define wxIslower iswlower
#define wxIsdigit iswdigit
#define wxIsgraph iswgraph
#define wxIslower iswlower
#define wxStrncat wcsncat
#define wxStrncmp wcsncmp
#define wxStrncpy wcsncpy
#define wxStrncat wcsncat
#define wxStrncmp wcsncmp
#define wxStrncpy wcsncpy
- /*
- #define wxNEED_FPUTWC
-
- #include <stdio.h>
-
- int wxFputs(const wxChar *ch, FILE *stream);
- int wxPutc(wxChar ch, FILE *stream);
-
- #define wxPuts(ws) wxFputs(ws, stdout)
- #define wxPutchar(wch) wxPutc(wch, stdout)
-
- #define wxNEED_PRINTF_CONVERSION
- #define wxNEED_WX_STDIO_H
- #define wxNEED_WX_STDLIB_H
- */
#define wxIsdigit isdigit
#define wxIsgraph isgraph
#define wxIslower islower
#define wxIsdigit isdigit
#define wxIsgraph isgraph
#define wxIslower islower
- /* wxStricmp and wxStrnicmp are defined below */
- #define wxStrlen_ strlen /* used in wxStrlen inline function */
+ /* wxStricmp and wxStrnicmp are defined below */
+ #define wxStrlen_ strlen /* used in wxStrlen inline function */
#define wxStrncat strncat
#define wxStrncmp strncmp
#define wxStrncpy strncpy
#define wxStrncat strncat
#define wxStrncmp strncmp
#define wxStrncpy strncpy
-/* define wxStricmp and wxStrnicmp for various compilers */
-/* */
-/* note that in Unicode mode we definitely are going to need our own version */
+/* define wxStricmp and wxStrnicmp for various compilers */
+
+/* note that in Unicode mode we definitely are going to need our own version */
#if !defined(wxStricmp) && !wxUSE_UNICODE
#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
defined(__SALFORDC__) || defined(__VISAGECPP__) || \
#if !defined(wxStricmp) && !wxUSE_UNICODE
#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
defined(__SALFORDC__) || defined(__VISAGECPP__) || \
#elif defined(__UNIX__) || defined(__GNUWIN32__)
#define wxStricmp strcasecmp
#define wxStrnicmp strncasecmp
#elif defined(__UNIX__) || defined(__GNUWIN32__)
#define wxStricmp strcasecmp
#define wxStrnicmp strncasecmp
-/* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
-/* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
-/* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
+/* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
+/* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
+/* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
-/* each of strdup() and wcsdup() may or may not be available but we need both */
-/* of them anyhow for wx/buffer.h so we define the missing one(s) in */
-/* wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW */
-/* defined -- if this is somehow not the case in some situations, please */
-/* correct that and not the lines here */
+/*
+ each of strdup() and wcsdup() may or may not be available but we need both
+ of them anyhow for wx/buffer.h so we define the missing one(s) in
+ wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
+ defined -- if this is somehow not the case in some situations, please
+ correct that and not the lines here
+ */
-/* ---------------------------------------------------------------------------- */
-/* printf() family saga */
-/* ---------------------------------------------------------------------------- */
+
+/* printf() family saga */
#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
extern "C"
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
extern "C"
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
WXDLLIMPEXP_BASE int wxSnprintf_(wxChar *buf, size_t len, const wxChar *format,
...) ATTRIBUTE_PRINTF_3;
#endif
WXDLLIMPEXP_BASE int wxSnprintf_(wxChar *buf, size_t len, const wxChar *format,
...) ATTRIBUTE_PRINTF_3;
#endif
- /* we need to implement all wide character printf and scanf functions */
- /* either because we don't have them at all or because they don't have the */
- /* semantics we need */
+ /*
+ we need to implement all wide character printf and scanf functions
+ either because we don't have them at all or because they don't have the
+ semantics we need
+ */
int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
int wxVprintf( const wxChar *format, va_list ap );
int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
int wxVprintf( const wxChar *format, va_list ap );
int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
-/* these 2 can be simply mapped to the versions with underscore at the end */
-/* if we don't have to do the conversion */
+/* these 2 can be simply mapped to the versions with underscore at the end */
+/* if we don't have to do the conversion */
#ifdef wxNEED_PRINTF_CONVERSION
int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
#ifdef wxNEED_PRINTF_CONVERSION
int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
-/* ---------------------------------------------------------------------------- */
-/* various functions which might not be available in libc and for which we */
-/* provide our own replacements in wxchar.cpp */
-/* ---------------------------------------------------------------------------- */
+/*
+ various functions which might not be available in libc and for which we
+ provide our own replacements in wxchar.cpp
+ */
+
+/* ctype.h functions */
WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
-/* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
-/* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
+/* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
+/* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
#undef wxIsspace
#define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
#undef wxIsspace
#define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
+/*
+ we had goofed and defined wxIctrl() instead of (correct) wxIscntrl() in the
+ initial versions of this header -- now it is too late to remove it so
+ although we fixed the function/macro name above, still provide the
+ backwards-compatible synonym.
+ */
+#define wxIsctrl wxIscntrl
+
+/* string.h functions */
#ifdef wxNEED_WX_STRING_H
WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
#ifdef wxNEED_WX_STRING_H
WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
#endif
WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
const wxChar *fmt, const struct tm *tm);
#endif
WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
const wxChar *fmt, const struct tm *tm);
-/* ---------------------------------------------------------------------------- */
-/* multibyte to wide char conversion functions and macros */
-/* ---------------------------------------------------------------------------- */
+/* multibyte to wide char conversion functions and macros */
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
#define wxMB2WC wxStrncpy
#define wxWC2MB wxStrncpy
#define wxMB2WX wxStrncpy
#define wxMB2WC wxStrncpy
#define wxWC2MB wxStrncpy
#define wxMB2WX wxStrncpy