X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8f93a29f8e50aa9dc6076a900ad6d316fafddcc3..5712a1f5fb57086dbf42d5c1c236bb1eb9bda857:/include/wx/chartype.h diff --git a/include/wx/chartype.h b/include/wx/chartype.h index 934e13d1bc..73606a61e0 100644 --- a/include/wx/chartype.h +++ b/include/wx/chartype.h @@ -38,8 +38,8 @@ #endif /* !defined(wxUSE_WCHAR_T) */ /* Unicode support requires wchar_t */ -#if wxUSE_UNICODE && !wxUSE_WCHAR_T - #error "wchar_t must be available in Unicode build" +#if !wxUSE_WCHAR_T + #error "wchar_t must be available" #endif /* Unicode */ /* @@ -145,7 +145,7 @@ typedef char wxChar; typedef signed char wxSChar; typedef unsigned char wxUChar; -#else /* Unicode */ +#else /* 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 */ @@ -154,8 +154,8 @@ /* Sun's SunPro compiler supports the wchar_t type and wide character */ /* functions, but does not define __WCHAR_TYPE__. Define it here to */ /* allow unicode enabled builds. */ - #if defined(__SUNPRO_CC) || defined(__SUNPRO_C) - #define __WCHAR_TYPE__ wxchar_t + #if (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && !defined(__WCHAR_TYPE__) + #define __WCHAR_TYPE__ wxchar_t #endif /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */ @@ -190,20 +190,33 @@ /* depending on the platform, Unicode build can either store wxStrings as wchar_t* or UTF-8 encoded char*: */ #if wxUSE_UNICODE - /* for now, all Unicode builds are wchar_t* based: */ - #define wxUSE_UNICODE_WCHAR 1 - #define wxUSE_UNICODE_UTF8 0 + /* FIXME-UTF8: what would be better place for this? */ + #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 + + #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 #else #define wxUSE_UNICODE_WCHAR 0 #define wxUSE_UNICODE_UTF8 0 + #define wxUSE_UTF8_LOCALE_ONLY 0 #endif /* define char type used by wxString internal representation: */ -#if wxUSE_UNICODE_UTF8 - typedef char wxStringCharType; -#elif wxUSE_UNICODE_WCHAR +#if wxUSE_UNICODE_WCHAR typedef wchar_t wxStringCharType; -#else +#else /* wxUSE_UNICODE_UTF8 || ANSI */ typedef char wxStringCharType; #endif @@ -228,6 +241,18 @@ #endif /* ASCII/Unicode */ #endif /* !defined(_T) */ +/* + 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 + #define wxS(x) wxCONCAT_HELPER(L, x) +#else /* wxUSE_UNICODE_UTF8 || ANSI */ + #define wxS(x) x +#endif + /* 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 wxWidgets sources */