| Version: 3.1.5

Macros | Typedefs
chartype.h File Reference

## Macros
#define | wxT(string)
| This macro can be used with character and string literals (in other words, `'x'` or `"foo"`) to automatically convert them to wide strings in Unicode builds of wxWidgets. More...
#define | wxT_2(string)
| Compatibility macro which expands to wxT() in wxWidgets 2 only. More...
#define | wxS(string)
| wxS is a macro which can be used with character and string literals (in other words, `'x'` or `"foo"`) to convert them either to wide characters or wide strings in `wchar_t-based` (UTF-16) builds, or to keep them unchanged in `char-based` (UTF-8) builds. More...
#define | _T(string)
| This macro is exactly the same as wxT() and is defined in wxWidgets simply because it may be more intuitive for Windows programmers as the standard Win32 headers also define it (as well as yet another name for the same macro which is _TEXT()). More...

## Typedefs
typedef wxUSE_UNICODE_dependent | wxChar
| wxChar is defined to be - `char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default). More...
typedef wxUSE_UNICODE_dependent | wxSChar
| wxSChar is defined to be - `signed char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default). More...
typedef wxUSE_UNICODE_dependent | wxUChar
| wxUChar is defined to be - `unsigned char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default). More...
typedef wxUSE_UNICODE_WCHAR_dependent | wxStringCharType
| wxStringCharType is defined to be: - `char` when `wxUSE_UNICODE==0` - `char` when `wxUSE_UNICODE_WCHAR==0` and `wxUSE_UNICODE==1` - `wchar_t` when `wxUSE_UNICODE_WCHAR==1` and `wxUSE_UNICODE==1` More...

## Macro Definition Documentation

## ◆ _T

#define _T | ( |  | string | ) |

This macro is exactly the same as wxT() and is defined in wxWidgets simply because it may be more intuitive for Windows programmers as the standard Win32 headers also define it (as well as yet another name for the same macro which is _TEXT()).

Don't confuse this macro with _()!

Note that since wxWidgets 2.9.0 the use of _T() is discouraged just like for wxT() and also that this macro may conflict with identifiers defined in standard headers of some compilers (such as Sun CC) so its use should really be avoided.

Include file:

    #include <wx/chartype.h>

## ◆ wxS

#define wxS | ( |  | string | ) |

wxS is a macro which can be used with character and string literals (in other words, `'x'` or `"foo"`) to convert them either to wide characters or wide strings in `wchar_t-based` (UTF-16) builds, or to keep them unchanged in `char-based` (UTF-8) builds.

Basically this macro produces characters or strings of type wxStringCharType.

The use of this macro is optional as the translation will always be done at run-time even if there is a mismatch between the kind of the literal used and the string or character type used in the current build. However using it can be beneficial in performance-sensitive code to do the conversion at compile-time instead.

See also
  Unicode Support in wxWidgets, wxT()

Include file:

    #include <wx/chartype.h>

## ◆ wxT

#define wxT | ( |  | string | ) |

This macro can be used with character and string literals (in other words, `'x'` or `"foo"`) to automatically convert them to wide strings in Unicode builds of wxWidgets.

This macro simply returns the value passed to it without changes in ASCII build. In fact, its definition is:

#ifdef UNICODE
# define wxT(x) L##x
#else // !Unicode
# define wxT(x) x
#endif

Note that since wxWidgets 2.9.0 you shouldn't use wxT() anymore in your program sources (it was previously required if you wanted to support Unicode).

See also
  Unicode Support in wxWidgets, wxS()

Include file:

    #include <wx/chartype.h>

## ◆ wxT_2

#define wxT_2 | ( |  | string | ) |

Compatibility macro which expands to wxT() in wxWidgets 2 only.

This macro can be used in code which needs to compile with both wxWidgets 2 and 3 versions, in places where the wx2 API requires a Unicode string (in Unicode build) but the wx3 API only accepts a standard narrow string, as in e.g. wxCmdLineEntryDesc structure objects initializers.

Example of use:

const wxCmdLineEntryDesc cmdLineDesc[] =
{
{ wxCMD_LINE_SWITCH, wxT_2("q"), wxT_2("quiet"),
wxT_2("Don't output verbose messages") },
wxCMD_LINE_DESC_END
};
wxT_2
#define wxT_2(string)
Compatibility macro which expands to wxT() in wxWidgets 2 only.
Definition: chartype.h:61
wxCMD_LINE_SWITCH
@ wxCMD_LINE_SWITCH
A boolean argument of the program; e.g. -v to enable verbose mode.
Definition: cmdline.h:69
wxCmdLineEntryDesc
The structure wxCmdLineEntryDesc is used to describe a command line switch, option or parameter.
Definition: cmdline.h:120

Without `wxT_2` the code above wouldn't compile with wxWidgets 2, but using `wxT` instead, it wouldn't compile with wxWidgets 3.

See also
  wxT()

Since
  2.8.12, 2.9.2

Include file:

    #include <wx/chartype.h>

## Typedef Documentation

## ◆ wxChar

typedef wxUSE_UNICODE_dependent wxChar

wxChar is defined to be - `char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default).

## ◆ wxSChar

typedef wxUSE_UNICODE_dependent wxSChar

wxSChar is defined to be - `signed char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default).

## ◆ wxStringCharType

typedef wxUSE_UNICODE_WCHAR_dependent wxStringCharType

wxStringCharType is defined to be: - `char` when `wxUSE_UNICODE==0` - `char` when `wxUSE_UNICODE_WCHAR==0` and `wxUSE_UNICODE==1` - `wchar_t` when `wxUSE_UNICODE_WCHAR==1` and `wxUSE_UNICODE==1`

The `wxUSE_UNICODE_WCHAR` symbol is defined to `1` when building on Windows while it's defined to `0` when building on Unix, Linux or macOS. (Note that `wxUSE_UNICODE_UTF8` symbol is defined as the opposite of `wxUSE_UNICODE_WCHAR`.)

Note that wxStringCharType (as the name says) is the type used by wxString for internal storage of the characters.

## ◆ wxUChar

typedef wxUSE_UNICODE_dependent wxUChar

wxUChar is defined to be - `unsigned char` when `wxUSE_UNICODE==0` - `wchar_t` when `wxUSE_UNICODE==1` (the default).