X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/436bb9f539b73a12f1f46af36e923459eec7a5f3..5b077ec744c49b77a9efdb050556e361c0865bb7:/include/wx/unichar.h diff --git a/include/wx/unichar.h b/include/wx/unichar.h index 8896425f1e..b7fe54d9ca 100644 --- a/include/wx/unichar.h +++ b/include/wx/unichar.h @@ -18,7 +18,7 @@ // wint_t is just a typedef for wchar_t for many old compilers but for modern // ones it's a separate type and we must provide a conversion to it to allow // passing wxUniChar[Ref] to functions taking wint_t such as iswalnum() &c -#if (defined(__GNUC__) && !defined(__DARWIN__)) || \ +#if (defined(__GNUC__) && !defined(__DARWIN__) && !defined(__OS2__)) || \ (defined(__VISUALC__) && defined(_NATIVE_WCHAR_T_DEFINED)) #define wxWINT_T_IS_SEPARATE_TYPE #endif @@ -31,6 +31,12 @@ #define wxIF_WINT_T_TYPE(x) #endif // wxWINT_T_IS_SEPARATE_TYPE/!wxWINT_T_IS_SEPARATE_TYPE +// wchar_t seems to be defined as unsigned short by all Windows compilers but +// unsigned int everywhere else +#ifndef __WIN32__ + #define wxWCHAR_T_IS_UINT +#endif + class WXDLLIMPEXP_BASE wxUniCharRef; // This class represents single Unicode character. It can be converted to @@ -69,6 +75,9 @@ public: operator char() const { return To8bit(m_value); } operator wchar_t() const { return m_value; } operator int() const { return m_value; } +#ifndef wxWCHAR_T_IS_UINT + operator unsigned int() const { return m_value; } +#endif // More conversions needed for other standard functions: uchar is for VC++ // _mbxxx() ones (to which toxxx/isxxx() are mapped when _MBCS is defined) @@ -98,6 +107,7 @@ public: wxUniChar& operator=(const wxUniChar& c) { m_value = c.m_value; return *this; } wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; } wxUniChar& operator=(wchar_t c) { m_value = c; return *this; } + wxUniChar& operator=(int c) { m_value = c; return *this; } #ifdef wxWINT_T_IS_SEPARATE_TYPE wxUniChar& operator=(wint_t c) { m_value = c; return *this; } #endif @@ -170,6 +180,7 @@ public: wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); } wxUniCharRef& operator=(wchar_t c) { return *this = wxUniChar(c); } + wxUniCharRef& operator=(int c) { return *this = wxUniChar(c); } #ifdef wxWINT_T_IS_SEPARATE_TYPE wxUniCharRef& operator=(wint_t c) { return *this = wxUniChar(c); } #endif @@ -182,6 +193,9 @@ public: #ifdef wxWINT_T_IS_SEPARATE_TYPE operator wint_t() const { return UniChar(); } #endif +#ifndef wxWCHAR_T_IS_UINT + operator unsigned int() const { return UniChar(); } +#endif // see wxUniChar::operator bool etc. for explanation operator bool() const { return (bool)UniChar(); }