2007-03-19 10:45:38 -04:00
|
|
|
/*
|
|
|
|
* Name: wx/chartype.h
|
|
|
|
* Purpose: Declarations of wxChar and related types
|
2009-09-18 12:16:12 -04:00
|
|
|
* Author: Joel Farley, Ove Kåven
|
2007-03-19 10:45:38 -04:00
|
|
|
* Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
|
|
|
|
* Created: 1998/06/12
|
|
|
|
* Copyright: (c) 1998-2006 wxWidgets dev team
|
|
|
|
* Licence: wxWindows licence
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
|
|
|
|
|
|
|
|
#ifndef _WX_WXCHARTYPE_H_
|
|
|
|
#define _WX_WXCHARTYPE_H_
|
|
|
|
|
2018-01-07 16:43:24 -05:00
|
|
|
/*
|
|
|
|
wx/defs.h indirectly includes this file, so we can't include it here,
|
|
|
|
include just its subset which defines SIZEOF_WCHAR_T that is used here
|
|
|
|
(under Unix it's in configure-generated setup.h, so including wx/platform.h
|
|
|
|
would have been enough, but this is not the case under other platforms).
|
|
|
|
*/
|
|
|
|
#include "wx/types.h"
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2019-10-30 16:18:15 -04:00
|
|
|
/* This is kept only for backwards compatibility, in case some application code
|
|
|
|
checks for it. It's always 1 and can't be changed. */
|
|
|
|
#define wxUSE_WCHAR_T 1
|
2007-03-19 10:45:38 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
2014-05-16 09:01:06 -04:00
|
|
|
#if defined(__MINGW32__)
|
2007-03-19 10:45:38 -04:00
|
|
|
#ifndef HAVE_WCHAR_H
|
|
|
|
#define HAVE_WCHAR_H
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-04-16 06:43:18 -04:00
|
|
|
#ifdef HAVE_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 */
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#endif /* Cygwin */
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2010-04-16 06:43:18 -04:00
|
|
|
#include <wchar.h>
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2010-04-16 06:43:18 -04:00
|
|
|
#if defined(__CYGWIN__) && defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif /* Cygwin and C++ */
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2014-08-23 21:50:11 -04:00
|
|
|
/* the current (as of Mar 2014) version of Android (up to api level 19) */
|
|
|
|
/* doesn't include some declarations (wscdup, wcslen, wcscasecmp, etc.) */
|
|
|
|
/* (moved out from __CYGWIN__ block) */
|
|
|
|
#if defined(__WXQT__) && !defined(wcsdup) && defined(__ANDROID__)
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
extern wchar_t *wcsdup(const wchar_t *);
|
|
|
|
extern size_t wcslen (const wchar_t *);
|
|
|
|
extern size_t wcsnlen (const wchar_t *, size_t );
|
|
|
|
extern int wcscasecmp (const wchar_t *, const wchar_t *);
|
|
|
|
extern int wcsncasecmp (const wchar_t *, const wchar_t *, size_t);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* Android */
|
|
|
|
|
2010-04-16 06:43:18 -04:00
|
|
|
#elif defined(HAVE_WCSTR_H)
|
|
|
|
/* old compilers have relevant declarations here */
|
|
|
|
#include <wcstr.h>
|
2014-05-15 19:56:58 -04:00
|
|
|
#elif defined(__FreeBSD__) || defined(__DARWIN__)
|
2010-04-16 06:43:18 -04:00
|
|
|
/* include stdlib.h for wchar_t */
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif /* HAVE_WCHAR_H */
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2010-04-16 06:43:18 -04:00
|
|
|
#ifdef HAVE_WIDEC_H
|
|
|
|
#include <widec.h>
|
|
|
|
#endif
|
2007-03-19 10:45:38 -04:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* 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() */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* VC++ and BC++ starting with 5.2 have TCHAR support */
|
2013-10-14 11:08:06 -04:00
|
|
|
#ifdef __VISUALC__
|
2007-03-19 10:45:38 -04:00
|
|
|
#define wxHAVE_TCHAR_SUPPORT
|
2017-09-04 16:38:23 -04:00
|
|
|
#elif defined(__MINGW32__)
|
2007-03-19 10:45:38 -04:00
|
|
|
#define wxHAVE_TCHAR_SUPPORT
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#endif /* compilers with (good) TCHAR support */
|
|
|
|
|
|
|
|
#ifdef wxHAVE_TCHAR_SUPPORT
|
|
|
|
/* get TCHAR definition if we've got it */
|
|
|
|
#include <tchar.h>
|
|
|
|
#endif /* wxHAVE_TCHAR_SUPPORT */
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* define wxChar type */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* TODO: define wxCharInt to be equal to either int or wint_t? */
|
|
|
|
|
|
|
|
#if !wxUSE_UNICODE
|
|
|
|
typedef char wxChar;
|
|
|
|
typedef signed char wxSChar;
|
|
|
|
typedef unsigned char wxUChar;
|
2008-07-29 07:01:16 -04:00
|
|
|
#else
|
2007-03-19 10:45:38 -04:00
|
|
|
/* 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 */
|
2014-05-16 09:01:35 -04:00
|
|
|
typedef wchar_t wxChar;
|
|
|
|
typedef wchar_t wxSChar;
|
|
|
|
typedef wchar_t wxUChar;
|
2007-03-19 10:45:38 -04:00
|
|
|
#endif /* ASCII/Unicode */
|
|
|
|
|
2007-03-26 16:28:04 -04:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* define wxStringCharType */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* depending on the platform, Unicode build can either store wxStrings as
|
|
|
|
wchar_t* or UTF-8 encoded char*: */
|
|
|
|
#if wxUSE_UNICODE
|
2007-06-25 11:07:20 -04:00
|
|
|
/* FIXME-UTF8: what would be better place for this? */
|
2007-04-23 16:42:13 -04:00
|
|
|
#if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8)
|
|
|
|
#error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8"
|
|
|
|
#endif
|
|
|
|
#ifndef wxUSE_UTF8_LOCALE_ONLY
|
|
|
|
#define wxUSE_UTF8_LOCALE_ONLY 0
|
|
|
|
#endif
|
|
|
|
|
2007-04-12 17:15:07 -04:00
|
|
|
#ifndef wxUSE_UNICODE_UTF8
|
|
|
|
#define wxUSE_UNICODE_UTF8 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE_UTF8
|
|
|
|
#define wxUSE_UNICODE_WCHAR 0
|
|
|
|
#else
|
|
|
|
#define wxUSE_UNICODE_WCHAR 1
|
|
|
|
#endif
|
2007-03-26 16:28:04 -04:00
|
|
|
#else
|
|
|
|
#define wxUSE_UNICODE_WCHAR 0
|
|
|
|
#define wxUSE_UNICODE_UTF8 0
|
2007-04-23 17:52:57 -04:00
|
|
|
#define wxUSE_UTF8_LOCALE_ONLY 0
|
2007-03-26 16:28:04 -04:00
|
|
|
#endif
|
2017-06-21 13:08:27 -04:00
|
|
|
|
|
|
|
#ifndef SIZEOF_WCHAR_T
|
|
|
|
#error "SIZEOF_WCHAR_T must be defined before including this file in wx/defs.h"
|
|
|
|
#endif
|
2007-03-26 16:28:04 -04:00
|
|
|
|
2017-04-24 02:56:35 -04:00
|
|
|
#if wxUSE_UNICODE_WCHAR && SIZEOF_WCHAR_T == 2
|
|
|
|
#define wxUSE_UNICODE_UTF16 1
|
|
|
|
#else
|
|
|
|
#define wxUSE_UNICODE_UTF16 0
|
|
|
|
#endif
|
|
|
|
|
2007-03-26 16:28:04 -04:00
|
|
|
/* define char type used by wxString internal representation: */
|
2008-01-02 11:31:38 -05:00
|
|
|
#if wxUSE_UNICODE_WCHAR
|
2007-03-26 16:28:04 -04:00
|
|
|
typedef wchar_t wxStringCharType;
|
2008-01-02 11:31:38 -05:00
|
|
|
#else /* wxUSE_UNICODE_UTF8 || ANSI */
|
2007-03-26 16:28:04 -04:00
|
|
|
typedef char wxStringCharType;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-03-19 10:45:38 -04:00
|
|
|
/* ------------------------------------------------------------------------- */
|
2009-07-23 16:30:22 -04:00
|
|
|
/* define wxT() and related macros */
|
2007-03-19 10:45:38 -04:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* BSD systems define _T() to be something different in ctype.h, override it */
|
|
|
|
#if defined(__FreeBSD__) || defined(__DARWIN__)
|
|
|
|
#include <ctype.h>
|
|
|
|
#undef _T
|
|
|
|
#endif
|
|
|
|
|
2009-07-23 16:30:22 -04:00
|
|
|
/*
|
|
|
|
wxT ("wx text") macro turns a literal string constant into a wide char
|
|
|
|
constant. It is mostly unnecessary with wx 2.9 but defined for
|
|
|
|
compatibility.
|
|
|
|
*/
|
|
|
|
#ifndef wxT
|
2007-03-19 10:45:38 -04:00
|
|
|
#if !wxUSE_UNICODE
|
2009-07-23 16:30:22 -04:00
|
|
|
#define wxT(x) x
|
2007-03-19 10:45:38 -04:00
|
|
|
#else /* Unicode */
|
2010-11-07 08:16:20 -05:00
|
|
|
/*
|
|
|
|
Notice that we use an intermediate macro to allow x to be expanded
|
|
|
|
if it's a macro itself.
|
|
|
|
*/
|
2020-10-13 12:32:49 -04:00
|
|
|
#define wxT(x) wxCONCAT_HELPER(L, x)
|
2007-03-19 10:45:38 -04:00
|
|
|
#endif /* ASCII/Unicode */
|
2009-07-23 16:30:22 -04:00
|
|
|
#endif /* !defined(wxT) */
|
2007-03-19 10:45:38 -04:00
|
|
|
|
2011-02-19 08:44:19 -05:00
|
|
|
/*
|
|
|
|
wxT_2 exists only for compatibility with wx 2.x and is the same as wxT() in
|
|
|
|
that version but nothing in the newer ones.
|
|
|
|
*/
|
|
|
|
#define wxT_2(x) x
|
|
|
|
|
2008-01-02 11:31:38 -05:00
|
|
|
/*
|
|
|
|
wxS ("wx string") macro can be used to create literals using the same
|
|
|
|
representation as wxString does internally, i.e. wchar_t in Unicode build
|
|
|
|
under Windows or char in UTF-8-based Unicode builds and (deprecated) ANSI
|
|
|
|
builds everywhere (see wxStringCharType definition above).
|
|
|
|
*/
|
|
|
|
#if wxUSE_UNICODE_WCHAR
|
2010-11-07 08:16:20 -05:00
|
|
|
/*
|
|
|
|
As above with wxT(), wxS() argument is expanded if it's a macro.
|
|
|
|
*/
|
2020-10-13 12:32:49 -04:00
|
|
|
#define wxS(x) wxCONCAT_HELPER(L, x)
|
2008-01-02 11:31:38 -05:00
|
|
|
#else /* wxUSE_UNICODE_UTF8 || ANSI */
|
|
|
|
#define wxS(x) x
|
|
|
|
#endif
|
|
|
|
|
2009-07-23 16:30:22 -04:00
|
|
|
/*
|
|
|
|
_T() is a synonym for wxT() familiar to Windows programmers. As this macro
|
|
|
|
has even higher risk of conflicting with system headers, its use is
|
|
|
|
discouraged and you may predefine wxNO__T to disable it. Additionally, we
|
|
|
|
do it ourselves for Sun CC which is known to use it in its standard headers
|
|
|
|
(see #10660).
|
|
|
|
*/
|
|
|
|
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
|
|
|
#ifndef wxNO__T
|
|
|
|
#define wxNO__T
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(_T) && !defined(wxNO__T)
|
|
|
|
#define _T(x) wxT(x)
|
|
|
|
#endif
|
2007-03-19 10:45:38 -04:00
|
|
|
|
|
|
|
/* a helper macro allowing to make another macro Unicode-friendly, see below */
|
2009-07-23 16:30:22 -04:00
|
|
|
#define wxAPPLY_T(x) wxT(x)
|
2007-03-19 10:45:38 -04:00
|
|
|
|
|
|
|
/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
|
|
|
|
#ifndef __TFILE__
|
|
|
|
#define __TFILE__ wxAPPLY_T(__FILE__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __TDATE__
|
|
|
|
#define __TDATE__ wxAPPLY_T(__DATE__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __TTIME__
|
|
|
|
#define __TTIME__ wxAPPLY_T(__TIME__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _WX_WXCHARTYPE_H_ */
|
|
|
|
|