From 4519d8e08a063ccdbdf183c3ce1f3fbed358c27f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 27 Oct 2022 02:43:51 +0100 Subject: [PATCH] Remove wxUSE_UNICODE checks as they're always true now Also remove all code guarded by "#if !wxUSE_UNICODE". --- include/wx/app.h | 6 +- include/wx/buffer.h | 28 +- include/wx/catch_cppunit.h | 2 - include/wx/chartype.h | 72 ++-- include/wx/chkconf.h | 8 - include/wx/cmdargs.h | 4 - include/wx/cmdline.h | 6 - include/wx/dataobj.h | 20 +- include/wx/datstrm.h | 4 - include/wx/debug.h | 3 - include/wx/defs.h | 23 +- include/wx/dynlib.h | 12 +- include/wx/event.h | 6 - include/wx/filefn.h | 69 +--- include/wx/generic/private/addremovectrl.h | 8 - include/wx/gtk/dvrenderers.h | 6 - include/wx/gtk/private.h | 66 +--- include/wx/hashmap.h | 2 - include/wx/html/htmlpars.h | 16 +- include/wx/html/winpars.h | 17 - include/wx/hyperlink.h | 3 +- include/wx/init.h | 8 - include/wx/msw/gccpriv.h | 7 +- include/wx/msw/private/msgdlg.h | 2 +- include/wx/msw/stackwalk.h | 6 +- include/wx/msw/textctrl.h | 9 - include/wx/msw/uxtheme.h | 41 +- include/wx/msw/wrapcctl.h | 2 +- include/wx/platform.h | 3 +- include/wx/private/wxprintf.h | 26 -- include/wx/richtext/richtextsymboldlg.h | 15 - include/wx/sstream.h | 2 - include/wx/stc/private.h | 22 -- include/wx/strconv.h | 47 +-- include/wx/string.h | 123 +----- include/wx/stringops.h | 5 +- include/wx/strvararg.h | 15 +- include/wx/translation.h | 18 +- include/wx/txtstrm.h | 20 +- include/wx/unichar.h | 10 - include/wx/utils.h | 2 - include/wx/wxcrt.h | 84 ++--- include/wx/wxcrtbase.h | 19 +- include/wx/wxcrtvararg.h | 20 +- include/wx/x11/app.h | 2 - include/wx/x11/dcclient.h | 2 - include/wx/x11/private.h | 9 +- include/wx/xlocale.h | 117 +++--- include/wx/xml/xml.h | 14 - include/wx/xtitypes.h | 2 +- samples/dataview/dataview.cpp | 9 +- samples/ipc/connection.h | 2 - samples/keyboard/keyboard.cpp | 8 - samples/printing/printing.cpp | 2 - samples/propgrid/propgrid.cpp | 4 - samples/text/text.cpp | 6 - samples/typetest/typetest.cpp | 6 - samples/typetest/typetest.h | 2 - samples/xti/codereadercallback.cpp | 4 - src/common/accelcmn.cpp | 8 +- src/common/appbase.cpp | 10 +- src/common/cmdline.cpp | 10 - src/common/datetimefmt.cpp | 2 - src/common/datstrm.cpp | 17 - src/common/dynlib.cpp | 2 - src/common/event.cpp | 2 - src/common/ffile.cpp | 4 - src/common/file.cpp | 4 - src/common/fileconf.cpp | 15 +- src/common/filefn.cpp | 19 - src/common/http.cpp | 5 - src/common/init.cpp | 30 +- src/common/intl.cpp | 6 +- src/common/ipcbase.cpp | 2 - src/common/regex.cpp | 6 +- src/common/sstream.cpp | 17 - src/common/string.cpp | 74 ++-- src/common/stringops.cpp | 4 +- src/common/strvararg.cpp | 29 +- src/common/tarstrm.cpp | 13 - src/common/textcmn.cpp | 5 +- src/common/textentrycmn.cpp | 2 - src/common/tokenzr.cpp | 4 - src/common/translation.cpp | 80 +--- src/common/txtstrm.cpp | 55 +-- src/common/utilscmn.cpp | 4 +- src/common/valnum.cpp | 9 - src/common/valtext.cpp | 6 - src/common/wxcrt.cpp | 28 -- src/common/xtixml.cpp | 5 - src/common/zipstrm.cpp | 9 - src/dfb/app.cpp | 12 - src/dfb/window.cpp | 16 - src/generic/aboutdlgg.cpp | 2 - src/generic/grideditors.cpp | 7 - src/generic/htmllbox.cpp | 4 - src/generic/logg.cpp | 5 +- src/generic/odcombo.cpp | 8 - src/gtk/aboutdlg.cpp | 12 - src/gtk/app.cpp | 10 - src/gtk/clipbrd.cpp | 10 - src/gtk/dataobj.cpp | 20 - src/gtk/dataview.cpp | 23 +- src/gtk/textctrl.cpp | 23 -- src/gtk/utilsgtk.cpp | 46 --- src/gtk/window.cpp | 15 - src/html/helpdata.cpp | 8 +- src/html/htmlfilt.cpp | 12 - src/html/htmlpars.cpp | 36 -- src/html/m_layout.cpp | 9 - src/html/winpars.cpp | 147 +------- src/msw/app.cpp | 6 - src/msw/artmsw.cpp | 15 - src/msw/control.cpp | 14 - src/msw/dde.cpp | 57 +-- src/msw/hyperlink.cpp | 4 +- src/msw/listctrl.cpp | 41 +- src/msw/main.cpp | 43 --- src/msw/notebook.cpp | 4 - src/msw/ole/dataobj.cpp | 17 +- src/msw/ole/oleutils.cpp | 16 +- src/msw/registry.cpp | 4 - src/msw/stdpaths.cpp | 6 - src/msw/taskbarbutton.cpp | 7 - src/msw/textctrl.cpp | 356 +++--------------- src/msw/utilsexc.cpp | 6 - src/msw/window.cpp | 54 +-- src/osx/carbon/app.cpp | 9 - src/osx/carbon/dataobj.cpp | 10 - src/osx/carbon/utilscocoa.mm | 8 - src/osx/cocoa/msgdlg.mm | 8 - src/osx/cocoa/window.mm | 5 +- src/osx/core/cfstring.cpp | 17 +- src/osx/core/strconv_cf.cpp | 7 - src/qt/app.cpp | 4 - src/qt/dataobj.cpp | 2 - src/qt/window.cpp | 2 - src/regex/regc_locale.c | 128 ------- src/regex/regcustom.h | 16 +- src/regex/regex.h | 10 +- src/richtext/richtextbuffer.cpp | 14 - src/richtext/richtextctrl.cpp | 12 - src/richtext/richtexthtml.cpp | 8 - src/richtext/richtextsymboldlg.cpp | 45 --- src/richtext/richtextxml.cpp | 56 +-- src/stc/PlatWX.cpp | 19 +- src/stc/ScintillaWX.cpp | 9 +- src/stc/gen_iface.py | 7 +- src/stc/stc.cpp | 19 +- src/stc/stc.cpp.in | 12 - src/univ/textctrl.cpp | 4 - src/unix/dir.cpp | 4 - src/unix/mediactrl.cpp | 9 +- src/unix/mediactrl_gstplayer.cpp | 9 +- src/unix/uilocale.cpp | 4 - src/unix/utilsunx.cpp | 6 - src/x11/app.cpp | 5 - src/x11/clipbrd.cpp | 4 - src/x11/dcclient.cpp | 123 ------ src/x11/dcscreen.cpp | 2 - src/x11/font.cpp | 309 --------------- src/x11/toplevel.cpp | 7 - src/x11/window.cpp | 49 --- src/xml/xml.cpp | 53 --- src/xrc/xmlres.cpp | 15 - tests/allheaders.cpp | 7 +- tests/any/anytest.cpp | 2 - tests/benchmarks/htmlparser/htmlpars.cpp | 33 -- tests/benchmarks/htmlparser/htmlpars.h | 11 +- tests/benchmarks/printfbench.cpp | 6 +- tests/datetime/datetimetest.cpp | 2 - tests/events/keyboard.cpp | 2 - tests/events/timertest.cpp | 5 - tests/file/filefn.cpp | 22 -- tests/file/filetest.cpp | 8 - tests/formatconverter/formatconvertertest.cpp | 4 +- tests/intl/intltest.cpp | 9 - tests/mbconv/convautotest.cpp | 5 - tests/mbconv/mbconvtest.cpp | 10 +- tests/regex/regextest.cpp | 8 - tests/streams/datastreamtest.cpp | 2 - tests/streams/sstream.cpp | 2 - tests/streams/textstreamtest.cpp | 13 +- tests/strings/crt.cpp | 2 - tests/strings/iostream.cpp | 2 +- tests/strings/stdstrings.cpp | 4 - tests/strings/strings.cpp | 18 - tests/strings/tokenizer.cpp | 4 - tests/strings/unichar.cpp | 4 - tests/strings/unicode.cpp | 33 -- tests/strings/vsnprintf.cpp | 4 - tests/textfile/textfiletest.cpp | 8 - tests/uris/uris.cpp | 2 - tests/xlocale/xlocale.cpp | 8 - tests/xml/xmltest.cpp | 2 - 195 files changed, 400 insertions(+), 3509 deletions(-) diff --git a/include/wx/app.h b/include/wx/app.h index e6dcbb434d..87ab2d052a 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -473,11 +473,7 @@ public: // type of argv parameter of main()) or to "wchar_t **" (for compatibility // with Unicode build in previous wx versions and because the command line // can, in pr -#if wxUSE_UNICODE wxCmdLineArgsArray argv; -#else - char **argv; -#endif protected: // delete all objects in wxPendingDelete list @@ -825,7 +821,7 @@ public: // locale (under Unix UTF-8, capable of representing any Unicode string, is // almost always used and there is no way to retrieve the Unicode command line // anyhow). -#if wxUSE_UNICODE && defined(__WINDOWS__) +#if defined(__WINDOWS__) #ifdef __VISUALC__ #define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ int wmain(int argc, wchar_t **argv) \ diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 74cbcf8e7d..619fd32d55 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -411,26 +411,18 @@ typedef wxWritableCharTypeBuffer wxWritableCharBuffer; typedef wxWritableCharTypeBuffer wxWritableWCharBuffer; -#if wxUSE_UNICODE - #define wxWxCharBuffer wxWCharBuffer +// Compatibility defines, don't use them in the new code. +#define wxWxCharBuffer wxWCharBuffer - #define wxMB2WXbuf wxWCharBuffer - #define wxWX2MBbuf wxCharBuffer - #if wxUSE_UNICODE_WCHAR - #define wxWC2WXbuf wxChar* - #define wxWX2WCbuf wxChar* - #elif wxUSE_UNICODE_UTF8 - #define wxWC2WXbuf wxWCharBuffer - #define wxWX2WCbuf wxWCharBuffer - #endif -#else // ANSI - #define wxWxCharBuffer wxCharBuffer - - #define wxMB2WXbuf wxChar* - #define wxWX2MBbuf wxChar* - #define wxWC2WXbuf wxCharBuffer +#define wxMB2WXbuf wxWCharBuffer +#define wxWX2MBbuf wxCharBuffer +#if wxUSE_UNICODE_WCHAR + #define wxWC2WXbuf wxChar* + #define wxWX2WCbuf wxChar* +#elif wxUSE_UNICODE_UTF8 + #define wxWC2WXbuf wxWCharBuffer #define wxWX2WCbuf wxWCharBuffer -#endif // Unicode/ANSI +#endif // ---------------------------------------------------------------------------- // A class for holding growable data buffers (not necessarily strings) diff --git a/include/wx/catch_cppunit.h b/include/wx/catch_cppunit.h index b04d0825dc..f688077bd5 100644 --- a/include/wx/catch_cppunit.h +++ b/include/wx/catch_cppunit.h @@ -94,11 +94,9 @@ namespace Catch i != wxs.end(); ++i ) { -#if wxUSE_UNICODE if ( !iswprint(*i) ) s += wxString::Format(wxASCII_STR("\\u%04X"), *i).ToAscii(); else -#endif // wxUSE_UNICODE s += *i; } diff --git a/include/wx/chartype.h b/include/wx/chartype.h index f75fc2805f..9e7a177913 100644 --- a/include/wx/chartype.h +++ b/include/wx/chartype.h @@ -106,55 +106,37 @@ #endif /* wxHAVE_TCHAR_SUPPORT */ /* ------------------------------------------------------------------------- */ -/* define wxChar type */ +/* define wxChar type for compatibility only */ /* ------------------------------------------------------------------------- */ -/* 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; -#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 */ - /* definitions worked so keep it like this */ - typedef wchar_t wxChar; - typedef wchar_t wxSChar; - typedef wchar_t wxUChar; -#endif /* ASCII/Unicode */ +typedef wchar_t wxChar; +typedef wchar_t wxSChar; +typedef wchar_t wxUChar; /* ------------------------------------------------------------------------- */ /* define wxStringCharType */ /* ------------------------------------------------------------------------- */ -/* depending on the platform, Unicode build can either store wxStrings as +/* depending on the build options, strings can store their data either as wchar_t* or UTF-8 encoded char*: */ -#if wxUSE_UNICODE - /* 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 +/* 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 + #ifndef SIZEOF_WCHAR_T #error "SIZEOF_WCHAR_T must be defined before including this file in wx/defs.h" #endif @@ -189,15 +171,11 @@ compatibility. */ #ifndef wxT - #if !wxUSE_UNICODE - #define wxT(x) x - #else /* Unicode */ - /* - Notice that we use an intermediate macro to allow x to be expanded - if it's a macro itself. - */ - #define wxT(x) wxCONCAT_HELPER(L, x) - #endif /* ASCII/Unicode */ + /* + Notice that we use an intermediate macro to allow x to be expanded + if it's a macro itself. + */ + #define wxT(x) wxCONCAT_HELPER(L, x) #endif /* !defined(wxT) */ /* diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index a61adb24a8..bba409c542 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -370,14 +370,6 @@ # endif #endif /* !defined(wxUSE_TEXTFILE) */ -#ifndef wxUSE_UNICODE -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_UNICODE must be defined, please read comment near the top of this file." -# else -# define wxUSE_UNICODE 0 -# endif -#endif /* !defined(wxUSE_UNICODE) */ - #ifndef wxUSE_UNSAFE_WXSTRING_CONV # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_UNSAFE_WXSTRING_CONV must be defined, please read comment near the top of this file." diff --git a/include/wx/cmdargs.h b/include/wx/cmdargs.h index 552c42c54c..ff516484c9 100644 --- a/include/wx/cmdargs.h +++ b/include/wx/cmdargs.h @@ -16,8 +16,6 @@ // wxCmdLineArgsArray: helper class used by wxApp::argv // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - // this class is used instead of either "char **" or "wchar_t **" (neither of // which would be backwards compatible with all the existing code) for argv // field of wxApp @@ -148,7 +146,5 @@ inline bool operator&&(bool cond, const wxCmdLineArgsArray& array) return cond && !array.IsEmpty(); } -#endif // wxUSE_UNICODE - #endif // _WX_CMDARGS_H_ diff --git a/include/wx/cmdline.h b/include/wx/cmdline.h index ec7e9e5c44..c3b3c3c1a8 100644 --- a/include/wx/cmdline.h +++ b/include/wx/cmdline.h @@ -206,11 +206,9 @@ public: // default ctor or ctor giving the cmd line in either Unix or Win form wxCmdLineParser() { Init(); } wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); } -#if wxUSE_UNICODE wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); } wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv) { Init(); SetCmdLine(argc, argv); } -#endif // wxUSE_UNICODE wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); } // the same as above, but also gives the cmd line description - otherwise, @@ -219,23 +217,19 @@ public: { Init(); SetDesc(desc); } wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, char **argv) { Init(); SetCmdLine(argc, argv); SetDesc(desc); } -#if wxUSE_UNICODE wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); SetDesc(desc); } wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, const wxCmdLineArgsArray& argv) { Init(); SetCmdLine(argc, argv); SetDesc(desc); } -#endif // wxUSE_UNICODE wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline) { Init(); SetCmdLine(cmdline); SetDesc(desc); } // set cmd line to parse after using one of the ctors which don't do it void SetCmdLine(int argc, char **argv); -#if wxUSE_UNICODE void SetCmdLine(int argc, wxChar **argv); void SetCmdLine(int argc, const wxCmdLineArgsArray& argv); -#endif // wxUSE_UNICODE void SetCmdLine(const wxString& cmdline); // not virtual, don't use this class polymorphically diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 6e7ed6af01..5bed7a5b9d 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -315,13 +315,11 @@ private: // wxTextDataObject contains text data // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXQT__) - #define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ - #elif defined(__WXMAC__) - #define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ - #endif -#endif // wxUSE_UNICODE +#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXQT__) + #define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ +#elif defined(__WXMAC__) + #define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ +#endif class WXDLLIMPEXP_CORE wxHTMLDataObject : public wxDataObjectSimple { @@ -368,13 +366,7 @@ public: // ctor: you can specify the text here or in SetText(), or override // GetText() wxTextDataObject(const wxString& text = wxEmptyString) - : wxDataObjectSimple( -#if wxUSE_UNICODE - wxDF_UNICODETEXT -#else - wxDF_TEXT -#endif - ), + : wxDataObjectSimple(wxDF_UNICODETEXT), m_text(text) { } diff --git a/include/wx/datstrm.h b/include/wx/datstrm.h index 477da30ec6..c54d79aa8e 100644 --- a/include/wx/datstrm.h +++ b/include/wx/datstrm.h @@ -45,10 +45,8 @@ public: } #endif // wxUSE_APPLE_IEEE -#if wxUSE_UNICODE void SetConv( const wxMBConv &conv ); wxMBConv *GetConv() const { return m_conv; } -#endif protected: // Ctor and dtor are both protected, this class is never used directly but @@ -63,9 +61,7 @@ protected: bool m_useExtendedPrecision; #endif // wxUSE_APPLE_IEEE -#if wxUSE_UNICODE wxMBConv *m_conv; -#endif wxDECLARE_NO_COPY_CLASS(wxDataStreamBase); }; diff --git a/include/wx/debug.h b/include/wx/debug.h index 49260740a1..a8ca42e599 100644 --- a/include/wx/debug.h +++ b/include/wx/debug.h @@ -166,8 +166,6 @@ inline void wxDisableAsserts() { wxSetAssertHandler(nullptr); } (assert macros do it). */ -#if wxUSE_UNICODE - // these overloads are the ones typically used by debugging macros: we have to // provide wxChar* msg version because it's common to use wxT() in the macros // and finally, we can't use const wx(char)* msg = nullptr, because that would @@ -191,7 +189,6 @@ extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, const char *func, const char *cond, const wxChar *msg) ; -#endif /* wxUSE_UNICODE */ // this version is for compatibility with wx 2.8 Unicode build only, we don't // use it ourselves any more except in ANSI-only build in which case it is all diff --git a/include/wx/defs.h b/include/wx/defs.h index 1d43a41854..a38a90591a 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -413,12 +413,17 @@ typedef short int WXTYPE; /* Very common macros */ /* ---------------------------------------------------------------------------- */ -/* Printf-like attribute definitions to obtain warnings with GNU C/C++ */ -#if defined(__GNUC__) && !wxUSE_UNICODE +/* Printf-like attribute definitions which could be used to obtain warnings + with GNU C/C++ but unfortunately don't work any longer + + TODO: make this work with Unicode functions + +#if defined(__GNUC__) # define WX_ATTRIBUTE_FORMAT(like, m, n) __attribute__ ((__format__ (like, m, n))) #else -# define WX_ATTRIBUTE_FORMAT(like, m, n) -#endif +*/ + +#define WX_ATTRIBUTE_FORMAT(like, m, n) #ifndef WX_ATTRIBUTE_PRINTF # define WX_ATTRIBUTE_PRINTF(m, n) WX_ATTRIBUTE_FORMAT(__printf__, m, n) @@ -801,12 +806,8 @@ typedef short int WXTYPE; #define WXUNUSED(identifier) identifier #endif -/* some arguments are not used in unicode mode */ -#if wxUSE_UNICODE - #define WXUNUSED_IN_UNICODE(param) WXUNUSED(param) -#else - #define WXUNUSED_IN_UNICODE(param) param -#endif +/* Defined for compatibility only. */ +#define WXUNUSED_IN_UNICODE(param) WXUNUSED(param) /* unused parameters in non stream builds */ #if wxUSE_STREAMS @@ -2987,7 +2988,7 @@ typedef GtkWidget *WXWidget; #endif /* __WXGTK__ */ -#if defined(__WXGTK__) || (defined(__WXX11__) && wxUSE_UNICODE) +#if defined(__WXGTK__) || defined(__WXX11__) #define wxUSE_PANGO 1 #else #define wxUSE_PANGO 0 diff --git a/include/wx/dynlib.h b/include/wx/dynlib.h index caa9dcaa92..816c538391 100644 --- a/include/wx/dynlib.h +++ b/include/wx/dynlib.h @@ -290,20 +290,14 @@ public: } #ifdef __WINDOWS__ - // this function is useful for loading functions from the standard Windows - // DLLs: such functions have an 'A' (in ANSI build) or 'W' (in Unicode, or - // wide character build) suffix if they take string parameters + // This function is misnamed now as it always loads "W" symbol because we + // always use Unicode now, but keeps its old name for compatibility. static void *RawGetSymbolAorW(wxDllType handle, const wxString& name) { return RawGetSymbol ( handle, - name + -#if wxUSE_UNICODE - L'W' -#else - 'A' -#endif + name + L'W' ); } diff --git a/include/wx/event.h b/include/wx/event.h index 73b812ac28..e1ad32613b 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -2207,10 +2207,8 @@ public: // returns true iff this event's key code is of a certain type bool IsKeyInCategory(int category) const; -#if wxUSE_UNICODE // get the Unicode character corresponding to this key wxChar GetUnicodeKey() const { return m_uniChar; } -#endif // wxUSE_UNICODE // get the raw key code (platform-dependent) wxUint32 GetRawKeyCode() const { return m_rawCode; } @@ -2271,11 +2269,9 @@ public: long m_keyCode; -#if wxUSE_UNICODE // This contains the full Unicode character // in a character events in Unicode mode wxChar m_uniChar; -#endif // these fields contain the platform-specific information about // key that was pressed @@ -2308,9 +2304,7 @@ private: m_rawCode = evt.m_rawCode; m_rawFlags = evt.m_rawFlags; -#if wxUSE_UNICODE m_uniChar = evt.m_uniChar; -#endif m_isRepeat = evt.m_isRepeat; } diff --git a/include/wx/filefn.h b/include/wx/filefn.h index b61282ec35..5d22d7f413 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -246,66 +246,25 @@ enum wxPosixPermissions #define wxEof wxPOSIX_IDENT(eof) // then the functions taking strings + #define wxCRT_Open _wopen - // first the ANSI versions - #define wxCRT_OpenA wxPOSIX_IDENT(open) - #define wxCRT_AccessA wxPOSIX_IDENT(access) - #define wxCRT_ChmodA wxPOSIX_IDENT(chmod) - #define wxCRT_MkDirA wxPOSIX_IDENT(mkdir) - #define wxCRT_RmDirA wxPOSIX_IDENT(rmdir) + wxDECL_FOR_STRICT_MINGW32(int, _wopen, (const wchar_t*, int, ...)) + wxDECL_FOR_STRICT_MINGW32(int, _waccess, (const wchar_t*, int)) + wxDECL_FOR_STRICT_MINGW32(int, _wchmod, (const wchar_t*, int)) + wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*)) + wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*)) + wxDECL_FOR_STRICT_MINGW32(int, _wstati64, (const wchar_t*, struct _stati64*)) + + #define wxCRT_Access _waccess + #define wxCRT_Chmod _wchmod + #define wxCRT_MkDir _wmkdir + #define wxCRT_RmDir _wrmdir #ifdef wxHAS_HUGE_FILES - // MinGW-64 provides underscore-less versions of all file functions - // except for this one. - #ifdef __MINGW64_TOOLCHAIN__ - #define wxCRT_StatA _stati64 - #else - #define wxCRT_StatA wxPOSIX_IDENT(stati64) - #endif + #define wxCRT_Stat _wstati64 #else - #define wxCRT_StatA wxPOSIX_IDENT(stat) + #define wxCRT_Stat _wstat #endif - // then wide char ones - #if wxUSE_UNICODE - - #define wxCRT_OpenW _wopen - - wxDECL_FOR_STRICT_MINGW32(int, _wopen, (const wchar_t*, int, ...)) - wxDECL_FOR_STRICT_MINGW32(int, _waccess, (const wchar_t*, int)) - wxDECL_FOR_STRICT_MINGW32(int, _wchmod, (const wchar_t*, int)) - wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*)) - wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*)) - wxDECL_FOR_STRICT_MINGW32(int, _wstati64, (const wchar_t*, struct _stati64*)) - - #define wxCRT_AccessW _waccess - #define wxCRT_ChmodW _wchmod - #define wxCRT_MkDirW _wmkdir - #define wxCRT_RmDirW _wrmdir - #ifdef wxHAS_HUGE_FILES - #define wxCRT_StatW _wstati64 - #else - #define wxCRT_StatW _wstat - #endif - #endif // wxUSE_UNICODE - - - // finally the default char-type versions - #if wxUSE_UNICODE - #define wxCRT_Open wxCRT_OpenW - #define wxCRT_Access wxCRT_AccessW - #define wxCRT_Chmod wxCRT_ChmodW - #define wxCRT_MkDir wxCRT_MkDirW - #define wxCRT_RmDir wxCRT_RmDirW - #define wxCRT_Stat wxCRT_StatW - #else // !wxUSE_UNICODE - #define wxCRT_Open wxCRT_OpenA - #define wxCRT_Access wxCRT_AccessA - #define wxCRT_Chmod wxCRT_ChmodA - #define wxCRT_MkDir wxCRT_MkDirA - #define wxCRT_RmDir wxCRT_RmDirA - #define wxCRT_Stat wxCRT_StatA - #endif // wxUSE_UNICODE/!wxUSE_UNICODE - // constants (unless already defined by the user code) #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS diff --git a/include/wx/generic/private/addremovectrl.h b/include/wx/generic/private/addremovectrl.h index 2eea6fad1d..c546f159e0 100644 --- a/include/wx/generic/private/addremovectrl.h +++ b/include/wx/generic/private/addremovectrl.h @@ -44,20 +44,12 @@ public: private: static wxString GetAddButtonLabel() { -#if wxUSE_UNICODE return wchar_t(0xFF0B); // FULLWIDTH PLUS SIGN -#else - return "+"; -#endif } static wxString GetRemoveButtonLabel() { -#if wxUSE_UNICODE return wchar_t(0x2012); // FIGURE DASH -#else - return "-"; -#endif } }; diff --git a/include/wx/gtk/dvrenderers.h b/include/wx/gtk/dvrenderers.h index ba75ead80e..c77d10a841 100644 --- a/include/wx/gtk/dvrenderers.h +++ b/include/wx/gtk/dvrenderers.h @@ -203,12 +203,6 @@ private: wxString m_label; int m_value; -#if !wxUSE_UNICODE - // Flag used to indicate that we need to set the label because we were - // unable to do it in the ctor (see comments there). - bool m_needsToSetLabel; -#endif // !wxUSE_UNICODE - protected: wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer); }; diff --git a/include/wx/gtk/private.h b/include/wx/gtk/private.h index ce6efd5ad8..cd78c537c2 100644 --- a/include/wx/gtk/private.h +++ b/include/wx/gtk/private.h @@ -30,65 +30,15 @@ // and use it only to test for pango versions >= 1.16.0 extern const gchar *wx_pango_version_check(int major, int minor, int micro); -#if wxUSE_UNICODE - #define wxGTK_CONV(s) (s).utf8_str() - #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s)) - #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s)) - #define wxGTK_CONV_SYS(s) wxGTK_CONV((s)) +#define wxGTK_CONV(s) (s).utf8_str() +#define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s)) +#define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s)) +#define wxGTK_CONV_SYS(s) wxGTK_CONV((s)) - #define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s) - #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s) - #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s) - #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s) -#else - #include "wx/font.h" - - // convert the text between the given encoding and UTF-8 used by wxGTK - extern WXDLLIMPEXP_CORE wxCharBuffer - wxConvertToGTK(const wxString& s, - wxFontEncoding enc = wxFONTENCODING_SYSTEM); - - extern WXDLLIMPEXP_CORE wxCharBuffer - wxConvertFromGTK(const wxString& s, - wxFontEncoding enc = wxFONTENCODING_SYSTEM); - - // helper: use the encoding of the given font if it's valid - inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font) - { - return wxConvertToGTK(s, font.IsOk() ? font.GetEncoding() - : wxFONTENCODING_SYSTEM); - } - - inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font) - { - return wxConvertFromGTK(s, font.IsOk() ? font.GetEncoding() - : wxFONTENCODING_SYSTEM); - } - - // more helpers: allow passing GTK+ strings directly - inline wxCharBuffer - wxConvertFromGTK(const wxGtkString& gs, - wxFontEncoding enc = wxFONTENCODING_SYSTEM) - { - return wxConvertFromGTK(gs.c_str(), enc); - } - - inline wxCharBuffer - wxConvertFromGTK(const wxGtkString& gs, const wxFont& font) - { - return wxConvertFromGTK(gs.c_str(), font); - } - - #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font) - #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc)) - #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font)) - #define wxGTK_CONV_SYS(s) wxConvertToGTK((s)) - - #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font) - #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc)) - #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font)) - #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s)) -#endif +#define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s) +#define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s) +#define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s) +#define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s) // Define a macro for converting wxString to char* in appropriate encoding for // the file names. diff --git a/include/wx/hashmap.h b/include/wx/hashmap.h index ca63c5fe95..4f9316b51b 100644 --- a/include/wx/hashmap.h +++ b/include/wx/hashmap.h @@ -547,10 +547,8 @@ struct WXDLLIMPEXP_BASE wxStringEqual { return a == b; } bool operator()( const wxChar* a, const wxChar* b ) const noexcept { return wxStrcmp( a, b ) == 0; } -#if wxUSE_UNICODE bool operator()( const char* a, const char* b ) const noexcept { return strcmp( a, b ) == 0; } -#endif // wxUSE_UNICODE }; #ifdef wxNEEDS_WX_HASH_MAP diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h index d7b0a35aa5..bc4be92280 100644 --- a/include/wx/html/htmlpars.h +++ b/include/wx/html/htmlpars.h @@ -270,13 +270,8 @@ public: wxHtmlEntitiesParser(); virtual ~wxHtmlEntitiesParser(); - // Sets encoding of output string. - // Has no effect if wxUSE_UNICODE==1 -#if wxUSE_UNICODE + // Obsolete, has no effect. void SetEncoding(wxFontEncoding WXUNUSED(encoding)) {} -#else - void SetEncoding(wxFontEncoding encoding); -#endif // Parses entities in input and replaces them with respective characters // (with respect to output encoding) @@ -286,18 +281,9 @@ public: wxChar GetEntityChar(const wxString& entity) const; // Returns character that represents given Unicode code -#if wxUSE_UNICODE wxChar GetCharForCode(unsigned code) const { return (wxChar)code; } -#else - wxChar GetCharForCode(unsigned code) const; -#endif protected: -#if !wxUSE_UNICODE - wxMBConv *m_conv; - wxFontEncoding m_encoding; -#endif - wxDECLARE_NO_COPY_CLASS(wxHtmlEntitiesParser); }; diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h index 2a9a60d17b..679ebae7a0 100644 --- a/include/wx/html/winpars.h +++ b/include/wx/html/winpars.h @@ -142,13 +142,6 @@ public: // following space as being part of the same space run as before. void StopCollapsingSpaces() { m_tmpLastWasSpace = false; } -#if !wxUSE_UNICODE - void SetInputEncoding(wxFontEncoding enc); - wxFontEncoding GetInputEncoding() const { return m_InputEnc; } - wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; } - wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; } -#endif - // creates font depending on m_Font* members. virtual wxFont* CreateCurrentFont(); @@ -210,9 +203,6 @@ private: wxFont* m_FontsTable[2][2][2][2][7]; wxString m_FontsFacesTable[2][2][2][2][7]; -#if !wxUSE_UNICODE - wxFontEncoding m_FontsEncTable[2][2][2][2][7]; -#endif // table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off // state of these flags (from left to right): // [bold][italic][underlined][fixed_size] @@ -223,13 +213,6 @@ private: wxString m_FontFaceFixed, m_FontFaceNormal; // html font sizes and faces of fixed and proportional fonts -#if !wxUSE_UNICODE - wxChar m_nbsp; - wxFontEncoding m_InputEnc, m_OutputEnc; - // I/O font encodings - wxEncodingConverter *m_EncConv; -#endif - // current whitespace handling mode WhitespaceMode m_whitespaceMode; diff --git a/include/wx/hyperlink.h b/include/wx/hyperlink.h index 127f19291d..eecab1ddff 100644 --- a/include/wx/hyperlink.h +++ b/include/wx/hyperlink.h @@ -139,8 +139,7 @@ typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&); #if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__) #include "wx/gtk/hyperlink.h" -// Note that the native control is only available in Unicode version under MSW. -#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__) +#elif defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #include "wx/msw/hyperlink.h" #else #include "wx/generic/hyperlink.h" diff --git a/include/wx/init.h b/include/wx/init.h index ea542aea42..6d39fade5a 100644 --- a/include/wx/init.h +++ b/include/wx/init.h @@ -45,13 +45,9 @@ extern void WXDLLIMPEXP_BASE wxEntryCleanup(); extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv); // we overload wxEntry[Start]() to take "char **" pointers too -#if wxUSE_UNICODE - extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv); extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv); -#endif// wxUSE_UNICODE - // Under Windows we define additional wxEntry() overloads with signature // compatible with WinMain() and not the traditional main(). #ifdef __WINDOWS__ @@ -68,9 +64,7 @@ extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv); // call to wxInitialize() must be matched by wxUninitialize()) extern bool WXDLLIMPEXP_BASE wxInitialize(); extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, wxChar **argv); -#if wxUSE_UNICODE extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, char **argv); -#endif // clean up -- the library can't be used any more after the last call to // wxUninitialize() @@ -92,12 +86,10 @@ public: m_ok = wxInitialize(argc, argv); } -#if wxUSE_UNICODE wxInitializer(int& argc, char **argv) { m_ok = wxInitialize(argc, argv); } -#endif // wxUSE_UNICODE // has the initialization been successful? (explicit test) bool IsOk() const { return m_ok; } diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h index 1ec54f90bb..aee8732ed5 100644 --- a/include/wx/msw/gccpriv.h +++ b/include/wx/msw/gccpriv.h @@ -25,12 +25,7 @@ without them being defined, better give a clearer error right now. */ #if !defined(UNICODE) - #ifndef wxUSE_UNICODE - #error "wxUSE_UNICODE must be defined before including this header." - #endif - #if wxUSE_UNICODE - #error "UNICODE must be defined before including this header." - #endif + #error "UNICODE must be defined before including this header." #endif /* diff --git a/include/wx/msw/private/msgdlg.h b/include/wx/msw/private/msgdlg.h index 93b5e80d35..5fcc332f0d 100644 --- a/include/wx/msw/private/msgdlg.h +++ b/include/wx/msw/private/msgdlg.h @@ -17,7 +17,7 @@ // TD_WARNING_ICON being defined in the headers for this as this symbol is used // by the task dialogs only. Also notice that task dialogs are available for // Unicode applications only. -#if defined(TD_WARNING_ICON) && wxUSE_UNICODE +#if defined(TD_WARNING_ICON) #define wxHAS_MSW_TASKDIALOG #endif diff --git a/include/wx/msw/stackwalk.h b/include/wx/msw/stackwalk.h index 47b4e21e29..9aa21937e2 100644 --- a/include/wx/msw/stackwalk.h +++ b/include/wx/msw/stackwalk.h @@ -21,11 +21,7 @@ struct _EXCEPTION_POINTERS; struct _SYMBOL_INFO; struct _SYMBOL_INFOW; -#if wxUSE_UNICODE - #define wxSYMBOL_INFO _SYMBOL_INFOW -#else // !wxUSE_UNICODE - #define wxSYMBOL_INFO _SYMBOL_INFO -#endif // wxUSE_UNICODE/!wxUSE_UNICODE +#define wxSYMBOL_INFO _SYMBOL_INFOW // ---------------------------------------------------------------------------- // wxStackFrame diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index f00aa98233..ffc322a8ca 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -220,15 +220,6 @@ protected: // the limit is due to a previous call to SetMaxLength() and not built in) bool HasSpaceLimit(unsigned int *len) const; -#if wxUSE_RICHEDIT && !wxUSE_UNICODE - // replace the selection or the entire control contents with the given text - // in the specified encoding - bool StreamIn(const wxString& value, wxFontEncoding encoding, bool selOnly); - - // get the contents of the control out as text in the given encoding - wxString StreamOut(wxFontEncoding encoding, bool selOnly = false) const; -#endif // wxUSE_RICHEDIT - // replace the contents of the selection or of the entire control with the // given text void DoWriteText(const wxString& text, diff --git a/include/wx/msw/uxtheme.h b/include/wx/msw/uxtheme.h index bab5335172..483531c3dc 100644 --- a/include/wx/msw/uxtheme.h +++ b/include/wx/msw/uxtheme.h @@ -176,48 +176,9 @@ public: // Trivial default ctor. wxUxThemeFont() { } -#if wxUSE_UNICODE - // In Unicode build we always use LOGFONT anyhow so this class is - // completely trivial. + // This class is now completely trivial and should be removed. LPLOGFONTW GetPtr() { return &m_lfW; } const LOGFONTW& GetLOGFONT() { return m_lfW; } -#else // !wxUSE_UNICODE - // Return either LOGFONTA or LOGFONTW pointer as required by the current - // Windows version. - LPLOGFONTW GetPtr() - { - return UseLOGFONTW() ? &m_lfW - : reinterpret_cast(&m_lfA); - } - - // This method returns LOGFONT (i.e. LOGFONTA in ANSI build and LOGFONTW in - // Unicode one) which can be used with other, normal, Windows or wx - // functions. Internally it may need to transform LOGFONTW to LOGFONTA. - const LOGFONTA& GetLOGFONT() - { - if ( UseLOGFONTW() ) - { - // Most of the fields are the same in LOGFONTA and LOGFONTW so just - // copy everything by default. - memcpy(&m_lfA, &m_lfW, sizeof(m_lfA)); - - // But the face name must be converted from Unicode. - WideCharToMultiByte(CP_ACP, 0, m_lfW.lfFaceName, -1, - m_lfA.lfFaceName, sizeof(m_lfA.lfFaceName), - nullptr, nullptr); - } - - return m_lfA; - } - -private: - static bool UseLOGFONTW() - { - return wxGetWinVersion() >= wxWinVersion_Vista; - } - - LOGFONTA m_lfA; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE private: LOGFONTW m_lfW; diff --git a/include/wx/msw/wrapcctl.h b/include/wx/msw/wrapcctl.h index e19111ada5..a52d68293a 100644 --- a/include/wx/msw/wrapcctl.h +++ b/include/wx/msw/wrapcctl.h @@ -21,7 +21,7 @@ // Set Unicode format for a common control inline void wxSetCCUnicodeFormat(HWND hwnd) { - ::SendMessage(hwnd, CCM_SETUNICODEFORMAT, wxUSE_UNICODE, 0); + ::SendMessage(hwnd, CCM_SETUNICODEFORMAT, TRUE, 0); } #if wxUSE_GUI diff --git a/include/wx/platform.h b/include/wx/platform.h index 28a3f66641..10c3fffcc5 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -493,8 +493,7 @@ /* check the consistency of the settings in setup.h: note that this must be - done after setting wxUSE_UNICODE correctly as it is used in wx/chkconf.h - and after defining the compiler macros which are used in it too + done after defining the compiler macros used in wx/chkconf.h */ #include "wx/chkconf.h" diff --git a/include/wx/private/wxprintf.h b/include/wx/private/wxprintf.h index e82af1a0af..cd28e2b6cb 100644 --- a/include/wx/private/wxprintf.h +++ b/include/wx/private/wxprintf.h @@ -428,7 +428,6 @@ bool wxPrintfConvSpec::Parse(const CharType *format) break; case wxT('c'): -#if wxUSE_UNICODE if (ilen == -1) { // %hc == ANSI character @@ -439,23 +438,10 @@ bool wxPrintfConvSpec::Parse(const CharType *format) // %lc == %c == Unicode character m_type = wxPAT_WCHAR; } -#else - if (ilen == 1) - { - // %lc == Unicode character - m_type = wxPAT_WCHAR; - } - else - { - // %hc == %c == ANSI character - m_type = wxPAT_CHAR; - } -#endif done = true; break; case wxT('s'): -#if wxUSE_UNICODE if (ilen == -1) { // wx extension: we'll let %hs mean non-Unicode strings @@ -466,18 +452,6 @@ bool wxPrintfConvSpec::Parse(const CharType *format) // %ls == %s == Unicode string m_type = wxPAT_PWCHAR; } -#else - if (ilen == 1) - { - // %ls == Unicode string - m_type = wxPAT_PWCHAR; - } - else - { - // %s == %hs == ANSI string - m_type = wxPAT_PCHAR; - } -#endif done = true; break; diff --git a/include/wx/richtext/richtextsymboldlg.h b/include/wx/richtext/richtextsymboldlg.h index 8e58328d32..c6dfbc9139 100644 --- a/include/wx/richtext/richtextsymboldlg.h +++ b/include/wx/richtext/richtextsymboldlg.h @@ -32,13 +32,6 @@ class wxSymbolListCtrl; class wxStdDialogButtonSizer; ////@end forward declarations -// __UNICODE__ is a symbol used by DialogBlocks-generated code. -#ifndef __UNICODE__ -#if wxUSE_UNICODE -#define __UNICODE__ -#endif -#endif - /*! * Symbols */ @@ -110,19 +103,15 @@ public: /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FONT void OnFontCtrlSelected( wxCommandEvent& event ); -#if defined(__UNICODE__) /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_SUBSET void OnSubsetSelected( wxCommandEvent& event ); /// wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET void OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& event ); -#endif -#if defined(__UNICODE__) /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FROM void OnFromUnicodeSelected( wxCommandEvent& event ); -#endif /// wxEVT_UPDATE_UI event handler for wxID_OK void OnOkUpdate( wxUpdateUIEvent& event ); @@ -157,15 +146,11 @@ public: ////@begin wxSymbolPickerDialog member variables wxComboBox* m_fontCtrl; -#if defined(__UNICODE__) wxComboBox* m_subsetCtrl; -#endif wxSymbolListCtrl* m_symbolsCtrl; wxStaticText* m_symbolStaticCtrl; wxTextCtrl* m_characterCodeCtrl; -#if defined(__UNICODE__) wxComboBox* m_fromUnicodeCtrl; -#endif wxStdDialogButtonSizer* m_stdButtonSizer; wxString m_fontName; bool m_fromUnicode; diff --git a/include/wx/sstream.h b/include/wx/sstream.h index b5bab51385..0757cab7c3 100644 --- a/include/wx/sstream.h +++ b/include/wx/sstream.h @@ -89,10 +89,8 @@ private: // arbitrary 8 bit data wxMBConv& m_conv; -#if wxUSE_UNICODE // unconverted data from the last call to OnSysWrite() wxMemoryBuffer m_unconv; -#endif // wxUSE_UNICODE wxDECLARE_NO_COPY_CLASS(wxStringOutputStream); }; diff --git a/include/wx/stc/private.h b/include/wx/stc/private.h index f48a037894..9ef9fd86b5 100644 --- a/include/wx/stc/private.h +++ b/include/wx/stc/private.h @@ -16,8 +16,6 @@ //---------------------------------------------------------------------- // Utility functions used within wxSTC -#if wxUSE_UNICODE - extern wxString stc2wx(const char* str); extern wxString stc2wx(const char* str, size_t len); extern wxCharBuffer wx2stc(const wxString& str); @@ -31,24 +29,4 @@ inline size_t wx2stclen(const wxString& WXUNUSED(str), const wxCharBuffer& buf) return buf.length(); } -#else // not UNICODE - -inline wxString stc2wx(const char* str) { - return wxString(str); -} -inline wxString stc2wx(const char* str, size_t len) { - return wxString(str, len); -} -inline const char* wx2stc(const wxString& str) { - return str.mbc_str(); -} - -// As explained above, the buffer argument is only used in Unicode build. -inline size_t wx2stclen(const wxString& str, const char* WXUNUSED(buf)) -{ - return str.length(); -} - -#endif // UNICODE - #endif // _WX_STC_PRIVATE_H_ diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 211e03de04..5e21d5bf81 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -107,18 +107,11 @@ public: wxCharBuffer cWC2MB(const wchar_t *in, size_t inLen, size_t *outLen) const; - // convenience functions for converting MB or WC to/from wxWin default -#if wxUSE_UNICODE + // Obsolete convenience functions. wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } wxCharBuffer cWX2MB(const wchar_t *psz) const { return cWC2MB(psz); } const wchar_t* cWC2WX(const wchar_t *psz) const { return psz; } const wchar_t* cWX2WC(const wchar_t *psz) const { return psz; } -#else // ANSI - const char* cMB2WX(const char *psz) const { return psz; } - const char* cWX2MB(const char *psz) const { return psz; } - wxCharBuffer cWC2WX(const wchar_t *psz) const { return cWC2MB(psz); } - wxWCharBuffer cWX2WC(const char *psz) const { return cMB2WC(psz); } -#endif // Unicode/ANSI // return the maximum number of bytes that can be required to encode a // single character in this encoding, e.g. 4 for UTF-8 @@ -677,7 +670,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; // ---------------------------------------------------------------------------- // filenames are multibyte on Unix and widechar on Windows -#if wxMBFILES && wxUSE_UNICODE +#if wxMBFILES #define wxFNCONV(name) wxConvFileName->cWX2MB(name) #define wxFNSTRINGCAST wxMBSTRINGCAST #else @@ -693,31 +686,23 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; // macros for the most common conversions // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - #define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) - #define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s) +#define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) +#define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s) - // these functions should be used when the conversions really, really have - // to succeed (usually because we pass their results to a standard C - // function which would crash if we passed nullptr to it), so these functions - // always return a valid pointer if their argument is non-null +// these functions should be used when the conversions really, really have +// to succeed (usually because we pass their results to a standard C +// function which would crash if we passed nullptr to it), so these functions +// always return a valid pointer if their argument is non-null - inline wxWCharBuffer wxSafeConvertMB2WX(const char *s) - { - return wxConvWhateverWorks.cMB2WC(s); - } +inline wxWCharBuffer wxSafeConvertMB2WX(const char *s) +{ + return wxConvWhateverWorks.cMB2WC(s); +} - inline wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) - { - return wxConvWhateverWorks.cWC2MB(ws); - } -#else // ANSI - // no conversions to do - #define wxConvertWX2MB(s) (s) - #define wxConvertMB2WX(s) (s) - #define wxSafeConvertMB2WX(s) (s) - #define wxSafeConvertWX2MB(s) (s) -#endif // Unicode/ANSI +inline wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) +{ + return wxConvWhateverWorks.cWC2MB(ws); +} // Macro that indicates the default encoding for converting C strings // to wxString. It provides a default value for a const wxMBConv& diff --git a/include/wx/string.h b/include/wx/string.h index aba1ebb306..693f3b8d49 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -352,9 +352,8 @@ private: const wxMBConv& conv); #endif -#if !wxUSE_UNICODE_UTF8 // wxUSE_UNICODE_WCHAR or !wxUSE_UNICODE +#if !wxUSE_UNICODE_UTF8 // wxUSE_UNICODE_WCHAR // returns C string encoded as the implementation expects: - #if wxUSE_UNICODE static const wchar_t* ImplStr(const wchar_t* str) { return str ? str : wxT(""); } static const SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) @@ -365,20 +364,6 @@ private: static SubstrBufFromMB ImplStr(const char* str, size_t n, const wxMBConv& conv wxSTRING_DEFAULT_CONV_ARG) { return ConvertStr(str, n, conv); } - #else - static const char* ImplStr(const char* str, - const wxMBConv& WXUNUSED(conv) wxSTRING_DEFAULT_CONV_ARG) - { return str ? str : ""; } - static const SubstrBufFromMB ImplStr(const char* str, size_t n, - const wxMBConv& WXUNUSED(conv) wxSTRING_DEFAULT_CONV_ARG) - { return SubstrBufFromMB(str, (str && n == npos) ? wxStrlen(str) : n); } -#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING - static wxScopedCharBuffer ImplStr(const wchar_t* str) - { return ConvertStr(str, npos, wxConvLibc).data; } - static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) - { return ConvertStr(str, n, wxConvLibc); } -#endif // wxNO_IMPLICIT_WXSTRING_ENCODING - #endif // translates position index in wxString to/from index in underlying // wxStringImpl: @@ -1246,13 +1231,8 @@ public: #endif #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING - #if !wxUSE_UNICODE // ANSI build - // FIXME-UTF8: do this in UTF8 build #if wxUSE_UTF8_LOCALE_ONLY, too - wxString(const std::string& str) : m_impl(str) {} - #else // Unicode - wxString(const std::string& str) - { assign(str.c_str(), str.length()); } - #endif + wxString(const std::string& str) + { assign(str.c_str(), str.length()); } #endif // wxNO_IMPLICIT_WXSTRING_ENCODING #endif // wxUSE_STD_STRING @@ -1280,7 +1260,7 @@ public: } #endif - #if (!wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY) && wxUSE_STL_BASED_WXSTRING + #if wxUSE_UTF8_LOCALE_ONLY && wxUSE_STL_BASED_WXSTRING // wxStringImpl is std::string in the encoding we want #define wxStringToStdStringRetType const std::string& const std::string& ToStdString() const { return m_impl; } @@ -1597,16 +1577,8 @@ public: template wxCharTypeBuffer tchar_str(size_t *len = nullptr) const { -#if wxUSE_UNICODE // we need a helper dispatcher depending on type return wxPrivate::wxStringAsBufHelper::Get(*this, len); -#else // ANSI - // T can only be char in ANSI build - if ( len ) - *len = length(); - - return wxCharTypeBuffer::CreateNonOwned(wx_str(), length()); -#endif // Unicode build kind } // conversion to/from plain (i.e. 7 bit) ASCII: this is useful for @@ -1615,18 +1587,10 @@ public: // // the behaviour of these functions with the strings containing anything // else than 7 bit ASCII characters is undefined, use at your own risk. -#if wxUSE_UNICODE static wxString FromAscii(const char *ascii, size_t len); static wxString FromAscii(const char *ascii); static wxString FromAscii(char ascii); const wxScopedCharBuffer ToAscii(char replaceWith = '_') const; -#else // ANSI - static wxString FromAscii(const char *ascii) { return wxString( ascii ); } - static wxString FromAscii(const char *ascii, size_t len) - { return wxString( ascii, len ); } - static wxString FromAscii(char ascii) { return wxString( ascii ); } - const char *ToAscii(char WXUNUSED(replaceWith) = '_') const { return c_str(); } -#endif // Unicode/!Unicode // also provide unsigned char overloads as signed/unsigned doesn't matter // for 7 bit ASCII characters @@ -1764,7 +1728,6 @@ public: const wxScopedCharBuffer ToUTF8() const { return utf8_str(); } // functions for storing binary data in wxString: -#if wxUSE_UNICODE static wxString From8BitData(const char *data, size_t len) { return wxString(data, wxConvISO8859_1, len); } // version for NUL-terminated data: @@ -1772,15 +1735,6 @@ public: { return wxString(data, wxConvISO8859_1); } const wxScopedCharBuffer To8BitData() const { return mb_str(wxConvISO8859_1); } -#else // ANSI - static wxString From8BitData(const char *data, size_t len) - { return wxString(data, len); } - // version for NUL-terminated data: - static wxString From8BitData(const char *data) - { return wxString(data); } - const wxScopedCharBuffer To8BitData() const - { return wxScopedCharBuffer::CreateNonOwned(wx_str(), length()); } -#endif // Unicode/ANSI // conversions with (possible) format conversions: have to return a // buffer with temporary data @@ -1792,8 +1746,6 @@ public: // type differs because a function may either return pointer to the buffer // directly or have to use intermediate buffer for translation. -#if wxUSE_UNICODE - // this is an optimization: even though using mb_str(wxConvLibc) does the // same thing (i.e. returns pointer to internal representation as locale is // always an UTF-8 one) in wxUSE_UTF8_LOCALE_ONLY case, we can avoid the @@ -1820,7 +1772,7 @@ public: const wxScopedWCharBuffer wc_str() const { return AsWCharBuf(wxMBConvStrictUTF8()); } #endif - // for compatibility with !wxUSE_UNICODE version + // for compatibility only const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const { return wc_str(); } @@ -1830,23 +1782,6 @@ public: const wxWX2WCbuf fn_str() const { return wc_str(); } #endif // wxMBFILES/!wxMBFILES -#else // ANSI - const char* mb_str() const { return wx_str(); } - - // for compatibility with wxUSE_UNICODE version - const char* mb_str(const wxMBConv& WXUNUSED(conv)) const { return wx_str(); } - - const wxWX2MBbuf mbc_str() const { return mb_str(); } - - const wxScopedWCharBuffer wc_str(const wxMBConv& conv wxSTRING_DEFAULT_CONV_ARG) const - { return AsWCharBuf(conv); } - -#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING - const wxScopedCharBuffer fn_str() const - { return wxConvFile.cWC2WX( wc_str( wxConvLibc ) ); } -#endif // wxNO_IMPLICIT_WXSTRING_ENCODING -#endif // Unicode/ANSI - #if wxUSE_UNICODE_UTF8 const wxScopedWCharBuffer t_str() const { return wc_str(); } #elif wxUSE_UNICODE_WCHAR @@ -3253,11 +3188,7 @@ public: // as strpbrk() but starts at nStart, returns npos if not found size_t find_first_of(const wxString& str, size_t nStart = 0) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary { return find_first_of(str.wc_str(), nStart); } -#else - { return find_first_of(str.mb_str(), nStart); } -#endif // same as above #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING size_t find_first_of(const char* sz, size_t nStart = 0) const; @@ -3272,11 +3203,7 @@ public: { return find(c, nStart); } // find the last (starting from nStart) char from str in this string size_t find_last_of (const wxString& str, size_t nStart = npos) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary { return find_last_of(str.wc_str(), nStart); } -#else - { return find_last_of(str.mb_str(), nStart); } -#endif // same as above #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING size_t find_last_of (const char* sz, size_t nStart = npos) const; @@ -3294,11 +3221,7 @@ public: // as strspn() (starting from nStart), returns npos on failure size_t find_first_not_of(const wxString& str, size_t nStart = 0) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary { return find_first_not_of(str.wc_str(), nStart); } -#else - { return find_first_not_of(str.mb_str(), nStart); } -#endif // same as above #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING size_t find_first_not_of(const char* sz, size_t nStart = 0) const; @@ -3312,11 +3235,7 @@ public: size_t find_first_not_of(wxUniChar ch, size_t nStart = 0) const; // as strcspn() size_t find_last_not_of(const wxString& str, size_t nStart = npos) const -#if wxUSE_UNICODE // FIXME-UTF8: temporary { return find_last_not_of(str.wc_str(), nStart); } -#else - { return find_last_not_of(str.mb_str(), nStart); } -#endif // same as above #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING size_t find_last_not_of(const char* sz, size_t nStart = npos) const; @@ -3587,7 +3506,6 @@ private: }; -#if wxUSE_UNICODE // common mb_str() and wxCStrData::AsChar() helper: performs the conversion // and returns either m_convertedToChar.m_str (in which case its m_len is // also updated) or nullptr if it failed @@ -3635,7 +3553,6 @@ private: } ConvertedBuffer m_convertedToChar; -#endif // !wxUSE_UNICODE #if !wxUSE_UNICODE_WCHAR // common wc_str() and wxCStrData::AsWChar() helper for both UTF-8 and ANSI @@ -4212,13 +4129,13 @@ WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedCharBuf #endif // wxNO_IMPLICIT_WXSTRING_ENCODING WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&); -#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#if defined(HAVE_WOSTREAM) WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxString&); WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&); WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxScopedWCharBuffer&); -#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#endif // defined(HAVE_WOSTREAM) #endif // wxUSE_STD_IOSTREAM @@ -4259,39 +4176,19 @@ inline const wchar_t* wxCStrData::AsWChar() const m_str->AsWChar(wxConvLibc); #endif - // in Unicode build the string always has a valid Unicode representation - // and even if a conversion is needed (as in UTF8 case) it can't fail - // - // but in ANSI build the string contents might be not convertible to - // Unicode using the current locale encoding so we do need to check for - // errors -#if !wxUSE_UNICODE - if ( !p ) - { - // if conversion fails, return empty string and not nullptr to avoid - // crashes in code written with either wxWidgets 2 wxString or - // std::string behaviour in mind: neither of them ever returns nullptr - // from its c_str() and so we shouldn't either - // - // notice that the same is done in AsChar() below and - // wxString::wc_str() and mb_str() for the same reasons - return L""; - } -#endif // !wxUSE_UNICODE - return p + m_offset; } #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING inline const char* wxCStrData::AsChar() const { -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#if !wxUSE_UTF8_LOCALE_ONLY const char * const p = m_str->AsChar(wxConvLibc); if ( !p ) return ""; -#else // !wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY +#else // wxUSE_UTF8_LOCALE_ONLY const char * const p = m_str->mb_str(); -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#endif return p + m_offset; } diff --git a/include/wx/stringops.h b/include/wx/stringops.h index dd46e6616c..8e885fd8a0 100644 --- a/include/wx/stringops.h +++ b/include/wx/stringops.h @@ -22,8 +22,7 @@ // one for UTF-8 encoded char* string and one for "raw" wchar_t* strings (or // char* in ANSI build). -// FIXME-UTF8: only wchar after we remove ANSI build -#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE +#if wxUSE_UNICODE_WCHAR struct WXDLLIMPEXP_BASE wxStringOperationsWchar { // moves the iterator to the next Unicode character @@ -80,7 +79,7 @@ struct WXDLLIMPEXP_BASE wxStringOperationsWchar static wxUniChar DecodeChar(const wxStringImpl::const_iterator& i) { return *i; } }; -#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE +#endif // wxUSE_UNICODE_WCHAR #if wxUSE_UNICODE_UTF8 diff --git a/include/wx/strvararg.h b/include/wx/strvararg.h index e783b19556..16855d816a 100644 --- a/include/wx/strvararg.h +++ b/include/wx/strvararg.h @@ -214,7 +214,7 @@ private: wxScopedCharBuffer m_convertedChar; #endif // !wxUSE_UNICODE_WCHAR && !defined wx_NO_IMPLICIT_WXSTRING_ENCODING -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#if !wxUSE_UTF8_LOCALE_ONLY public: operator const wchar_t*() const { return const_cast(this)->AsWChar(); } @@ -222,7 +222,7 @@ private: const wchar_t* InputAsWChar(); const wchar_t* AsWChar(); wxScopedWCharBuffer m_convertedWChar; -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#endif // !wxUSE_UTF8_LOCALE_ONLY private: wxScopedCharBuffer m_char; @@ -398,12 +398,6 @@ wxFORMAT_STRING_SPECIFIER(long double, wxFormatString::Arg_LongDouble) wxFORMAT_STRING_SPECIFIER(wchar_t, wxFormatString::Arg_Char | wxFormatString::Arg_Int) #endif -#if !wxUSE_UNICODE && !defined wxNO_IMPLICIT_WXSTRING_ENCODING -wxFORMAT_STRING_SPECIFIER(char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(signed char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -wxFORMAT_STRING_SPECIFIER(unsigned char, wxFormatString::Arg_Char | wxFormatString::Arg_Int) -#endif - #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String) wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String) @@ -849,12 +843,11 @@ struct wxArgNormalizer : public wxArgNormalizer // for wchar_t, default handler does the right thing -// char has to be treated differently in Unicode builds: a char argument may +// char has to be treated differently: a char argument may // be used either for a character value (which should be converted into // wxUniChar) or as an integer value (which should be left as-is). We take // advantage of the fact that both char and wchar_t are converted into int // in variadic arguments here. -#if wxUSE_UNICODE template struct wxArgNormalizerNarrowChar { @@ -903,8 +896,6 @@ struct wxArgNormalizer : wxArgNormalizerNarrowChar(value, fmt, index) {} }; -#endif // wxUSE_UNICODE - // convert references: WX_ARG_NORMALIZER_FORWARD(wxUniChar, const wxUniChar&); WX_ARG_NORMALIZER_FORWARD(const wxUniCharRef&, const wxUniChar&); diff --git a/include/wx/translation.h b/include/wx/translation.h index 07c425885d..ed3027c8dd 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -86,9 +86,7 @@ class WXDLLIMPEXP_BASE wxMsgCatalog public: // Ctor is protected, because CreateFromXXX functions must be used, // but destruction should be unrestricted -#if !wxUSE_UNICODE - ~wxMsgCatalog(); -#endif + ~wxMsgCatalog() = default; // load the catalog from disk or from data; caller is responsible for // deleting them if not null @@ -107,9 +105,6 @@ public: protected: wxMsgCatalog(const wxString& domain) : m_pNext(nullptr), m_domain(domain) -#if !wxUSE_UNICODE - , m_conv(nullptr) -#endif {} private: @@ -120,12 +115,6 @@ private: wxStringToStringHashMap m_messages; // all messages in the catalog wxString m_domain; // name of the domain -#if !wxUSE_UNICODE - // the conversion corresponding to this catalog charset if we installed it - // as the global one - wxCSConv *m_conv; -#endif - wxPluralFormsCalculatorPtr m_pluralFormsCalculator; }; @@ -166,11 +155,6 @@ public: // wxTranslationsLoader bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage = wxLANGUAGE_ENGLISH_US); -#if !wxUSE_UNICODE - bool AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage, - const wxString& msgIdCharset); -#endif // check if the given catalog is loaded bool IsLoaded(const wxString& domain) const; diff --git a/include/wx/txtstrm.h b/include/wx/txtstrm.h index 4e769f1b4e..5abab12e9e 100644 --- a/include/wx/txtstrm.h +++ b/include/wx/txtstrm.h @@ -36,13 +36,9 @@ WXDLLIMPEXP_BASE wxTextOutputStream &endl( wxTextOutputStream &stream ); class WXDLLIMPEXP_BASE wxTextInputStream { public: -#if wxUSE_UNICODE wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t"), const wxMBConv& conv = wxConvAuto()); -#else - wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t")); -#endif ~wxTextInputStream(); const wxInputStream& GetInputStream() const { return m_input; } @@ -67,9 +63,9 @@ public: // Operators wxTextInputStream& operator>>(wxString& word); wxTextInputStream& operator>>(char& c); -#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE +#if wxWCHAR_T_IS_REAL_TYPE wxTextInputStream& operator>>(wchar_t& wc); -#endif // wxUSE_UNICODE +#endif wxTextInputStream& operator>>(wxInt16& i); wxTextInputStream& operator>>(wxInt32& i); wxTextInputStream& operator>>(wxInt64& i); @@ -101,7 +97,6 @@ protected: size_t m_validBegin, m_validEnd; -#if wxUSE_UNICODE wxMBConv *m_conv; // The second half of a surrogate character when using UTF-16 for wchar_t: @@ -112,7 +107,6 @@ protected: #if SIZEOF_WCHAR_T == 2 wchar_t m_lastWChar; #endif // SIZEOF_WCHAR_T == 2 -#endif // wxUSE_UNICODE bool EatEOL(const wxChar &c); void UngetLast(); // should be used instead of wxInputStream::Ungetch() because of Unicode issues @@ -132,13 +126,9 @@ enum wxEOL class WXDLLIMPEXP_BASE wxTextOutputStream { public: -#if wxUSE_UNICODE wxTextOutputStream(wxOutputStream& s, wxEOL mode = wxEOL_NATIVE, const wxMBConv& conv = wxConvAuto()); -#else - wxTextOutputStream(wxOutputStream& s, wxEOL mode = wxEOL_NATIVE); -#endif virtual ~wxTextOutputStream(); const wxOutputStream& GetOutputStream() const { return m_output; } @@ -168,9 +158,9 @@ public: wxTextOutputStream& operator<<(const wxString& string); wxTextOutputStream& operator<<(char c); -#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE +#if wxWCHAR_T_IS_REAL_TYPE wxTextOutputStream& operator<<(wchar_t wc); -#endif // wxUSE_UNICODE +#endif wxTextOutputStream& operator<<(wxInt16 c); wxTextOutputStream& operator<<(wxInt32 c); wxTextOutputStream& operator<<(wxInt64 c); @@ -186,7 +176,6 @@ protected: wxOutputStream &m_output; wxEOL m_mode; -#if wxUSE_UNICODE wxMBConv *m_conv; #if SIZEOF_WCHAR_T == 2 @@ -194,7 +183,6 @@ protected: // and couldn't be output when it was called the last time. wchar_t m_lastWChar; #endif // SIZEOF_WCHAR_T == 2 -#endif // wxUSE_UNICODE wxDECLARE_NO_COPY_CLASS(wxTextOutputStream); }; diff --git a/include/wx/unichar.h b/include/wx/unichar.h index 1f9d3874ca..c42285007b 100644 --- a/include/wx/unichar.h +++ b/include/wx/unichar.h @@ -72,7 +72,6 @@ public: // must be non-null) bool GetAsChar(char *c) const { -#if wxUSE_UNICODE if ( !IsAscii() ) { #if !wxUSE_UTF8_LOCALE_ONLY @@ -82,7 +81,6 @@ public: return false; } -#endif // wxUSE_UNICODE *c = wx_truncate_cast(char, m_value); return true; @@ -181,26 +179,18 @@ private: // characters purely for performance reasons static value_type From8bit(char c) { -#if wxUSE_UNICODE if ( (unsigned char)c < 0x80 ) return c; return FromHi8bit(c); -#else - return c; -#endif } static char To8bit(value_type c) { -#if wxUSE_UNICODE if ( c < 0x80 ) return wx_truncate_cast(char, c); return ToHi8bit(c); -#else - return wx_truncate_cast(char, c); -#endif } // helpers of the functions above called to deal with non-ASCII chars diff --git a/include/wx/utils.h b/include/wx/utils.h index 291be49532..239dc6f6f4 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -389,12 +389,10 @@ WXDLLIMPEXP_BASE long wxExecute(const char* const* argv, int flags = wxEXEC_ASYNC, wxProcess *process = nullptr, const wxExecuteEnv *env = nullptr); -#if wxUSE_UNICODE WXDLLIMPEXP_BASE long wxExecute(const wchar_t* const* argv, int flags = wxEXEC_ASYNC, wxProcess *process = nullptr, const wxExecuteEnv *env = nullptr); -#endif // wxUSE_UNICODE // execute the command capturing its output into an array line by line, this is // always synchronous diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index 8d9bfd93e1..aeb2bb9729 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -42,17 +42,11 @@ inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); } 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); -#if wxUSE_UNICODE - #define wxMB2WX wxMB2WC - #define wxWX2MB wxWC2MB - #define wxWC2WX wxStrncpy - #define wxWX2WC wxStrncpy -#else - #define wxMB2WX wxStrncpy - #define wxWX2MB wxStrncpy - #define wxWC2WX wxWC2MB - #define wxWX2WC wxMB2WC -#endif +// Obsolete helpers. +#define wxMB2WX wxMB2WC +#define wxWX2MB wxWC2MB +#define wxWC2WX wxStrncpy +#define wxWX2WC wxStrncpy // RN: We could do the usual tricky compiler detection here, @@ -64,47 +58,45 @@ WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); // #include -#if wxUSE_UNICODE - //implement our own wmem variants - inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l) - { - for(;l && *s != c;--l, ++s) {} +//implement our own wmem variants +inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l) +{ + for(;l && *s != c;--l, ++s) {} - if(l) - return const_cast(s); - return nullptr; - } + if(l) + return const_cast(s); + return nullptr; +} - inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len) - { - for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {} +inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len) +{ + for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {} - if(len) - return *sz1 < *sz2 ? -1 : *sz1 > *sz2; - else - return 0; - } + if(len) + return *sz1 < *sz2 ? -1 : *sz1 > *sz2; + else + return 0; +} - inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len) - { - return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar)); - } +inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len) +{ + return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar)); +} - inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len) - { - return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar)); - } +inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len) +{ + return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar)); +} - inline wxChar* wxTmemset(wxChar* szOut, wxChar cIn, size_t len) - { - wxChar* szRet = szOut; +inline wxChar* wxTmemset(wxChar* szOut, wxChar cIn, size_t len) +{ + wxChar* szRet = szOut; - while (len--) - *szOut++ = cIn; + while (len--) + *szOut++ = cIn; - return szRet; - } -#endif /* wxUSE_UNICODE */ + return szRet; +} // provide trivial wrappers for char* versions for both ANSI and Unicode builds // (notice that these intentionally return "char *" and not "void *" unlike the @@ -556,15 +548,11 @@ WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String) template inline int wxStrcoll_String(const wxString& s1, const T& s2) { -#if wxUSE_UNICODE // NB: strcoll() doesn't work correctly on UTF-8 strings, so we have to use // wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is // there just as optimization to avoid going through // wxStrcoll: return wxStrcoll((const wchar_t*)s1.wc_str(), s2); -#else - return wxStrcoll((const char*)s1.mb_str(), s2); -#endif } #endif // defined(wxCRT_Strcoll[AW]) diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index 71b3f6299a..ec1148b8d3 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -270,18 +270,11 @@ WXDLLIMPEXP_BASE int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t } #endif -/* FIXME-UTF8: remove this once we are Unicode only */ -#if wxUSE_UNICODE - #define wxCRT_StrlenNative wxCRT_StrlenW - #define wxCRT_StrncmpNative wxCRT_StrncmpW - #define wxCRT_ToupperNative wxCRT_ToupperW - #define wxCRT_TolowerNative wxCRT_TolowerW -#else - #define wxCRT_StrlenNative wxCRT_StrlenA - #define wxCRT_StrncmpNative wxCRT_StrncmpA - #define wxCRT_ToupperNative toupper - #define wxCRT_TolowerNative tolower -#endif +/* FIXME-UTF8: remove this */ +#define wxCRT_StrlenNative wxCRT_StrlenW +#define wxCRT_StrncmpNative wxCRT_StrncmpW +#define wxCRT_ToupperNative wxCRT_ToupperW +#define wxCRT_TolowerNative wxCRT_TolowerW #ifndef wxCRT_StrcatW WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcatW(wchar_t *dest, const wchar_t *src); @@ -413,7 +406,7 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha /* these functions are only needed in the form used for filenames (i.e. char* on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */ -#if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */ +#if wxMBFILES /* ANSI filenames */ #define wxCRT_Fopen fopen #define wxCRT_Freopen freopen diff --git a/include/wx/wxcrtvararg.h b/include/wx/wxcrtvararg.h index 8610aed84b..a7b7e13543 100644 --- a/include/wx/wxcrtvararg.h +++ b/include/wx/wxcrtvararg.h @@ -146,9 +146,7 @@ // for wxString code, define wxUSE_WXVSNPRINTF to indicate that wx // implementation is used no matter what (in UTF-8 build, either *A or *W // version may be called): -#if !wxUSE_UNICODE - #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA -#elif wxUSE_UNICODE_WCHAR +#if wxUSE_UNICODE_WCHAR #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFW #elif wxUSE_UTF8_LOCALE_ONLY #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA @@ -238,15 +236,9 @@ // user-friendly wrappers to CRT functions // ---------------------------------------------------------------------------- - // FIXME-UTF8: remove this -#if wxUSE_UNICODE - #define wxCRT_PrintfNative wxCRT_PrintfW - #define wxCRT_FprintfNative wxCRT_FprintfW -#else - #define wxCRT_PrintfNative wxCRT_PrintfA - #define wxCRT_FprintfNative wxCRT_FprintfA -#endif - +// FIXME-UTF8: remove this +#define wxCRT_PrintfNative wxCRT_PrintfW +#define wxCRT_FprintfNative wxCRT_FprintfW wxGCC_ONLY_WARNING_SUPPRESS(format-nonliteral) @@ -330,8 +322,6 @@ WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (char*, size_t, const wxFormatString&) int WXDLLIMPEXP_BASE wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr); -#if wxUSE_UNICODE - #if !wxUSE_UTF8_LOCALE_ONLY int WXDLLIMPEXP_BASE wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...); #endif @@ -356,8 +346,6 @@ WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (wchar_t*, size_t, const wxFormatStrin int WXDLLIMPEXP_BASE wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr); -#endif // wxUSE_UNICODE - // We can't use wxArgNormalizer for variadic arguments to wxScanf() etc. // because they are writable, so instead of providing friendly template // vararg-like functions, we just provide both char* and wchar_t* variants diff --git a/include/wx/x11/app.h b/include/wx/x11/app.h index c674fae3eb..d3dc058bd3 100644 --- a/include/wx/x11/app.h +++ b/include/wx/x11/app.h @@ -71,12 +71,10 @@ public: const wxSize& GetInitialSize() const { return m_initialSize; } bool GetShowIconic() const { return m_showIconic; } -#if wxUSE_UNICODE // Global context for Pango layout. Either use X11 // or use Xft rendering according to GDK_USE_XFT // environment variable PangoContext* GetPangoContext(); -#endif wxXVisualInfo* GetVisualInfo(WXDisplay* WXUNUSED(display)) { diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h index ee0fc16be5..37d45d944c 100644 --- a/include/wx/x11/dcclient.h +++ b/include/wx/x11/dcclient.h @@ -134,10 +134,8 @@ protected: wxRegion m_currentClippingRegion; wxRegion m_paintClippingRegion; -#if wxUSE_UNICODE PangoContext *m_context; PangoFontDescription *m_fontdesc; -#endif void SetUpDC(); void Destroy(); diff --git a/include/wx/x11/private.h b/include/wx/x11/private.h index d1436aec45..ce09cc4ae5 100644 --- a/include/wx/x11/private.h +++ b/include/wx/x11/private.h @@ -39,13 +39,8 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; // Some Unicode <-> UTF8 macros stolen from GTK // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - #define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s) - #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s) -#else - #define wxGTK_CONV(s) s.c_str() - #define wxGTK_CONV_BACK(s) s -#endif +#define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s) +#define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s) // ---------------------------------------------------------------------------- // we maintain a hash table which contains the mapping from Widget to wxWindow diff --git a/include/wx/xlocale.h b/include/wx/xlocale.h index 48c4516e09..f556c3ab7f 100644 --- a/include/wx/xlocale.h +++ b/include/wx/xlocale.h @@ -48,10 +48,7 @@ #include #include #include - - #if wxUSE_UNICODE - #include - #endif + #include // Locale type and identifier name typedef locale_t wxXLocale_t; @@ -250,71 +247,61 @@ extern WXDLLIMPEXP_DATA_BASE(wxXLocale) wxNullXLocale; inline unsigned long wxStrtoul_lA(const char *c, char **endptr, int base, const wxXLocale& loc) { return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } - #if wxUSE_UNICODE + // ctype functions + #define wxCRT_Isalnum_lW wxXLOCALE_IDENT(iswalnum_l) + #define wxCRT_Isalpha_lW wxXLOCALE_IDENT(iswalpha_l) + #define wxCRT_Iscntrl_lW wxXLOCALE_IDENT(iswcntrl_l) + #define wxCRT_Isdigit_lW wxXLOCALE_IDENT(iswdigit_l) + #define wxCRT_Isgraph_lW wxXLOCALE_IDENT(iswgraph_l) + #define wxCRT_Islower_lW wxXLOCALE_IDENT(iswlower_l) + #define wxCRT_Isprint_lW wxXLOCALE_IDENT(iswprint_l) + #define wxCRT_Ispunct_lW wxXLOCALE_IDENT(iswpunct_l) + #define wxCRT_Isspace_lW wxXLOCALE_IDENT(iswspace_l) + #define wxCRT_Isupper_lW wxXLOCALE_IDENT(iswupper_l) + #define wxCRT_Isxdigit_lW wxXLOCALE_IDENT(iswxdigit_l) + #define wxCRT_Tolower_lW wxXLOCALE_IDENT(towlower_l) + #define wxCRT_Toupper_lW wxXLOCALE_IDENT(towupper_l) - // ctype functions - #define wxCRT_Isalnum_lW wxXLOCALE_IDENT(iswalnum_l) - #define wxCRT_Isalpha_lW wxXLOCALE_IDENT(iswalpha_l) - #define wxCRT_Iscntrl_lW wxXLOCALE_IDENT(iswcntrl_l) - #define wxCRT_Isdigit_lW wxXLOCALE_IDENT(iswdigit_l) - #define wxCRT_Isgraph_lW wxXLOCALE_IDENT(iswgraph_l) - #define wxCRT_Islower_lW wxXLOCALE_IDENT(iswlower_l) - #define wxCRT_Isprint_lW wxXLOCALE_IDENT(iswprint_l) - #define wxCRT_Ispunct_lW wxXLOCALE_IDENT(iswpunct_l) - #define wxCRT_Isspace_lW wxXLOCALE_IDENT(iswspace_l) - #define wxCRT_Isupper_lW wxXLOCALE_IDENT(iswupper_l) - #define wxCRT_Isxdigit_lW wxXLOCALE_IDENT(iswxdigit_l) - #define wxCRT_Tolower_lW wxXLOCALE_IDENT(towlower_l) - #define wxCRT_Toupper_lW wxXLOCALE_IDENT(towupper_l) - - inline int wxIsalnum_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isalnum_lW(c, loc.Get()); } - inline int wxIsalpha_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isalpha_lW(c, loc.Get()); } - inline int wxIscntrl_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Iscntrl_lW(c, loc.Get()); } - inline int wxIsdigit_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isdigit_lW(c, loc.Get()); } - inline int wxIsgraph_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isgraph_lW(c, loc.Get()); } - inline int wxIslower_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Islower_lW(c, loc.Get()); } - inline int wxIsprint_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isprint_lW(c, loc.Get()); } - inline int wxIspunct_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Ispunct_lW(c, loc.Get()); } - inline int wxIsspace_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isspace_lW(c, loc.Get()); } - inline int wxIsupper_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isupper_lW(c, loc.Get()); } - inline int wxIsxdigit_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Isxdigit_lW(c, loc.Get()); } - inline wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Tolower_lW(c, loc.Get()); } - inline wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc) - { return wxCRT_Toupper_lW(c, loc.Get()); } + inline int wxIsalnum_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isalnum_lW(c, loc.Get()); } + inline int wxIsalpha_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isalpha_lW(c, loc.Get()); } + inline int wxIscntrl_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Iscntrl_lW(c, loc.Get()); } + inline int wxIsdigit_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isdigit_lW(c, loc.Get()); } + inline int wxIsgraph_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isgraph_lW(c, loc.Get()); } + inline int wxIslower_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Islower_lW(c, loc.Get()); } + inline int wxIsprint_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isprint_lW(c, loc.Get()); } + inline int wxIspunct_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Ispunct_lW(c, loc.Get()); } + inline int wxIsspace_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isspace_lW(c, loc.Get()); } + inline int wxIsupper_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isupper_lW(c, loc.Get()); } + inline int wxIsxdigit_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Isxdigit_lW(c, loc.Get()); } + inline wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Tolower_lW(c, loc.Get()); } + inline wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc) + { return wxCRT_Toupper_lW(c, loc.Get()); } - // stdlib functions for numeric <-> string conversion - // (see notes above about missing functions) - #define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l) - #define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l) - #define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l) + // stdlib functions for numeric <-> string conversion + // (see notes above about missing functions) + #define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l) + #define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l) + #define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l) - inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc) - { return wxCRT_Strtod_lW(c, endptr, loc.Get()); } - inline long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtol_lW(c, endptr, base, loc.Get()); } - inline unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtoul_lW(c, endptr, base, loc.Get()); } - #else // !wxUSE_UNICODE - inline double wxStrtod_l(const char *c, char **endptr, const wxXLocale& loc) - { return wxCRT_Strtod_lA(c, endptr, loc.Get()); } - inline long wxStrtol_l(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtol_lA(c, endptr, base, loc.Get()); } - inline unsigned long wxStrtoul_l(const char *c, char **endptr, int base, const wxXLocale& loc) - { return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } - #endif // wxUSE_UNICODE + inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc) + { return wxCRT_Strtod_lW(c, endptr, loc.Get()); } + inline long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtol_lW(c, endptr, base, loc.Get()); } + inline unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) + { return wxCRT_Strtoul_lW(c, endptr, base, loc.Get()); } #else // !wxHAS_XLOCALE_SUPPORT // ctype functions int WXDLLIMPEXP_BASE wxIsalnum_l(const wxUniChar& c, const wxXLocale& loc); diff --git a/include/wx/xml/xml.h b/include/wx/xml/xml.h index 04a906fa2e..0a72143985 100644 --- a/include/wx/xml/xml.h +++ b/include/wx/xml/xml.h @@ -88,9 +88,6 @@ private: // are irrelevant) and wxXML_ELEMENT_NODE (e.g. in hi there is // element with name="title", irrelevant content and one child (wxXML_TEXT_NODE // with content="hi"). -// -// If wxUSE_UNICODE is 0, all strings are encoded in the encoding given to Load -// (default is UTF-8). class WXDLLIMPEXP_XML wxXmlNode { @@ -280,22 +277,11 @@ public: void SetFileType(wxTextFileType fileType); void AppendToProlog(wxXmlNode *node); -#if !wxUSE_UNICODE - // Returns encoding of in-memory representation of the document - // (same as passed to Load or ctor, defaults to UTF-8). - // NB: this is meaningless in Unicode build where data are stored as wchar_t* - wxString GetEncoding() const { return m_encoding; } - void SetEncoding(const wxString& enc) { m_encoding = enc; } -#endif - static wxVersionInfo GetLibraryVersionInfo(); private: wxString m_version; wxString m_fileEncoding; -#if !wxUSE_UNICODE - wxString m_encoding; -#endif wxXmlDoctype m_doctype; wxXmlNode *m_docNode; wxTextFileType m_fileType; diff --git a/include/wx/xtitypes.h b/include/wx/xtitypes.h index e6e93df9e9..40b48562b5 100644 --- a/include/wx/xtitypes.h +++ b/include/wx/xtitypes.h @@ -314,7 +314,7 @@ public: { Register(); } -#if 0 // wxUSE_UNICODE +#if 0 wxTypeInfo(wxTypeKind kind, wxVariant2StringFnc to, wxString2VariantFnc from, const char *name): diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp index 1560ab8bd1..9313421952 100644 --- a/samples/dataview/dataview.cpp +++ b/samples/dataview/dataview.cpp @@ -823,10 +823,10 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, m_music_model = new MyMusicTreeModel; m_ctrl[Page_Music]->AssociateModel( m_music_model.get() ); -#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE +#if wxUSE_DRAG_AND_DROP m_ctrl[Page_Music]->EnableDragSource( wxDF_UNICODETEXT ); m_ctrl[Page_Music]->EnableDropTarget( wxDF_UNICODETEXT ); -#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE +#endif // wxUSE_DRAG_AND_DROP // column 0 of the view control: @@ -1768,12 +1768,9 @@ void MyFrame::OnSorted( wxDataViewEvent &event ) void MyFrame::OnDataViewChar(wxKeyEvent& event) { wxString key; -#if wxUSE_UNICODE if ( event.GetUnicodeKey() != WXK_NONE ) key.Printf("\"%c\"", event.GetUnicodeKey()); - else -#endif - if ( event.GetKeyCode() != WXK_NONE ) + else if ( event.GetKeyCode() != WXK_NONE ) key.Printf("wxKeyCode(%d)", event.GetKeyCode()); else key = "unknown key"; diff --git a/samples/ipc/connection.h b/samples/ipc/connection.h index 2a59e21edb..293e80df89 100644 --- a/samples/ipc/connection.h +++ b/samples/ipc/connection.h @@ -38,11 +38,9 @@ protected: s += wxString(static_cast(data), size); break; -#if wxUSE_UNICODE case wxIPC_UNICODETEXT: s += wxString(static_cast(data), size); break; -#endif // wxUSE_UNICODE case wxIPC_UTF8TEXT: s += wxString::FromUTF8(static_cast(data), size); diff --git a/samples/keyboard/keyboard.cpp b/samples/keyboard/keyboard.cpp index e12e9dafe0..e5b1e61afe 100644 --- a/samples/keyboard/keyboard.cpp +++ b/samples/keyboard/keyboard.cpp @@ -531,11 +531,9 @@ wxString GetKeyName(const wxKeyEvent &event) if ( keycode >= 32 && keycode < 128 ) return wxString::Format("'%c'", (unsigned char)keycode); -#if wxUSE_UNICODE int uc = event.GetUnicodeKey(); if ( uc != WXK_NONE ) return wxString::Format("'%c'", uc); -#endif return "unknown"; } @@ -546,11 +544,7 @@ void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event) wxString msg; // event key_name KeyCode modifiers Unicode raw_code raw_flags pos msg.Printf("%7s %15s %5d %c%c%c%c" -#if wxUSE_UNICODE "%5d (U+%04x)" -#else - " none " -#endif #ifdef wxHAS_RAW_KEY_CODES " %7lu 0x%08lx" #else @@ -566,10 +560,8 @@ void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event) event.AltDown() ? 'A' : '-', event.ShiftDown() ? 'S' : '-', event.MetaDown() ? 'M' : '-' -#if wxUSE_UNICODE , event.GetUnicodeKey() , event.GetUnicodeKey() -#endif #ifdef wxHAS_RAW_KEY_CODES , (unsigned long) event.GetRawKeyCode() , (unsigned long) event.GetRawKeyFlags() diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index ce107995b1..93fd462338 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -159,11 +159,9 @@ void MyApp::Draw(wxDC&dc) dc.DrawRotatedText( "This\nis\na multi-line\ntext", dc.FromDIP(170), dc.FromDIP(100), -m_angle/1.5); -#if wxUSE_UNICODE const char *test = "Hebrew שלום -- Japanese (日本語)"; wxString tmp = wxConvUTF8.cMB2WC( test ); dc.DrawText( tmp, dc.FromDIP(10), dc.FromDIP(200) ); -#endif wxPoint points[5]; points[0].x = 0; diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 5e96d1da66..4e73641bb7 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -2713,15 +2713,11 @@ void FormMain::OnAbout(wxCommandEvent& WXUNUSED(event)) wxString msg; msg.Printf( "wxPropertyGrid Sample" -#if wxUSE_UNICODE #if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8 " " #else " " #endif -#else - " " -#endif #ifdef __WXDEBUG__ " " #else diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 88d2329f07..6e512569f6 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -717,9 +717,7 @@ void MyTextCtrl::LogKeyEvent(const wxString& name, wxKeyEvent& event) const } } -#if wxUSE_UNICODE key += wxString::Format(" (Unicode: %#04x)", event.GetUnicodeKey()); -#endif // wxUSE_UNICODE wxLogMessage( "%s event: %s (flags = %c%c%c%c)", name, @@ -1184,11 +1182,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_horizontal->SetFont(wxFontInfo(18) .Family(wxFONTFAMILY_SWISS) .Encoding(wxFONTENCODING_CP1251)); -#if wxUSE_UNICODE m_horizontal->AppendText(L"\x0412\x0430\x0434\x0438\x043c \x0426"); -#else - m_horizontal->AppendText("\313\301\326\305\324\323\321 \325\304\301\336\316\331\315"); -#endif } } else diff --git a/samples/typetest/typetest.cpp b/samples/typetest/typetest.cpp index a738e18486..f21f285831 100644 --- a/samples/typetest/typetest.cpp +++ b/samples/typetest/typetest.cpp @@ -45,9 +45,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(MyApp, wxApp); wxBEGIN_EVENT_TABLE(MyApp, wxApp) EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo) EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo) -#if wxUSE_UNICODE EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo) -#endif // wxUSE_UNICODE EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo) EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2) EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3) @@ -83,9 +81,7 @@ bool MyApp::OnInit() wxMenu *test_menu = new wxMenu; test_menu->Append(TYPES_VARIANT, "&Variant test"); test_menu->Append(TYPES_BYTEORDER, "&Byteorder test"); -#if wxUSE_UNICODE test_menu->Append(TYPES_UNICODE, "&Unicode test"); -#endif // wxUSE_UNICODE test_menu->Append(TYPES_STREAM, "&Stream test"); test_menu->Append(TYPES_STREAM2, "&Stream seek test"); test_menu->Append(TYPES_STREAM3, "&Stream error test"); @@ -870,7 +866,6 @@ void MyApp::DoStreamDemo7(wxCommandEvent& WXUNUSED(event)) textCtrl.WriteText( str ); } -#if wxUSE_UNICODE void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event)) { wxTextCtrl& textCtrl = * GetTextCtrl(); @@ -889,7 +884,6 @@ void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event)) puts( str.mbc_str() ); } -#endif void MyApp::DoMIMEDemo(wxCommandEvent& WXUNUSED(event)) { diff --git a/samples/typetest/typetest.h b/samples/typetest/typetest.h index a36b42373b..c5781fd485 100644 --- a/samples/typetest/typetest.h +++ b/samples/typetest/typetest.h @@ -29,9 +29,7 @@ public: void DoStreamDemo5(wxCommandEvent& event); void DoStreamDemo6(wxCommandEvent& event); void DoStreamDemo7(wxCommandEvent& event); -#if wxUSE_UNICODE void DoUnicodeDemo(wxCommandEvent& event); -#endif // wxUSE_UNICODE void DoMIMEDemo(wxCommandEvent& event); wxTextCtrl* GetTextCtrl() const { return m_textCtrl; } diff --git a/samples/xti/codereadercallback.cpp b/samples/xti/codereadercallback.cpp index d1ad96a2ff..2cbf67ffc1 100644 --- a/samples/xti/codereadercallback.cpp +++ b/samples/xti/codereadercallback.cpp @@ -39,11 +39,7 @@ using namespace std; struct wxObjectCodeReaderCallback::wxObjectCodeReaderCallbackInternal { -#if wxUSE_UNICODE map m_objectNames; -#else - map m_objectNames; -#endif void SetObjectName(int objectID, const wxString &name ) { diff --git a/src/common/accelcmn.cpp b/src/common/accelcmn.cpp index 176862e4fa..07464fa554 100644 --- a/src/common/accelcmn.cpp +++ b/src/common/accelcmn.cpp @@ -380,13 +380,7 @@ wxString wxAcceleratorEntry::AsPossiblyLocalizedString(bool localized) const if ( n == WXSIZEOF(wxKeyNames) ) { // must be a simple key - if ( -#if !wxUSE_UNICODE - // we can't call wxIsalnum() for non-ASCII characters in ASCII - // build as they're only defined for the ASCII range (or EOF) - wxIsascii(code) && -#endif // ANSI - wxIsprint(code) ) + if ( wxIsprint(code) ) { text << (wxChar)code; } diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 46faf130c8..316237a513 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -142,12 +142,10 @@ wxAppConsoleBase::wxAppConsoleBase() #ifdef __WXDEBUG__ SetTraceMasks(); -#if wxUSE_UNICODE - // In unicode mode the SetTraceMasks call can cause an apptraits to be + // SetTraceMasks call can cause an apptraits to be // created, but since we are still in the constructor the wrong kind will // be created for GUI apps. Destroy it so it can be created again later. wxDELETE(m_traits); -#endif #endif wxEvtHandler::AddFilter(this); @@ -1173,12 +1171,10 @@ void wxOnAssert(const wxChar *file, const wxChar *cond, const wxChar *msg) { - // this is the backwards-compatible version (unless we don't use Unicode) + // this is the backwards-compatible version // so it could be called directly from the user code and this might happen // even when wxTheAssertHandler is null -#if wxUSE_UNICODE if ( wxTheAssertHandler ) -#endif // wxUSE_UNICODE wxTheAssertHandler(file, line, func, cond, msg); } @@ -1200,7 +1196,6 @@ void wxOnAssert(const char *file, wxTheAssertHandler(file, line, func, cond, msg); } -#if wxUSE_UNICODE void wxOnAssert(const char *file, int line, const char *func, @@ -1226,7 +1221,6 @@ void wxOnAssert(const char *file, { wxTheAssertHandler(file, line, func, cond, msg); } -#endif // wxUSE_UNICODE #endif // wxDEBUG_LEVEL diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index 56cdbac6c8..b9167c5493 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -206,10 +206,8 @@ struct wxCmdLineParserData // methods wxCmdLineParserData(); void SetArguments(int argc, char **argv); -#if wxUSE_UNICODE void SetArguments(int argc, wxChar **argv); void SetArguments(int argc, const wxCmdLineArgsArray& argv); -#endif // wxUSE_UNICODE void SetArguments(const wxString& cmdline); int FindOption(const wxString& name); @@ -443,8 +441,6 @@ void wxCmdLineParserData::SetArguments(int argc, char **argv) } } -#if wxUSE_UNICODE - void wxCmdLineParserData::SetArguments(int argc, wxChar **argv) { m_arguments.clear(); @@ -461,8 +457,6 @@ void wxCmdLineParserData::SetArguments(int WXUNUSED(argc), m_arguments = argv.GetArguments(); } -#endif // wxUSE_UNICODE - void wxCmdLineParserData::SetArguments(const wxString& cmdLine) { m_arguments.clear(); @@ -542,8 +536,6 @@ void wxCmdLineParser::SetCmdLine(int argc, char **argv) m_data->SetArguments(argc, argv); } -#if wxUSE_UNICODE - void wxCmdLineParser::SetCmdLine(int argc, wxChar **argv) { m_data->SetArguments(argc, argv); @@ -554,8 +546,6 @@ void wxCmdLineParser::SetCmdLine(int argc, const wxCmdLineArgsArray& argv) m_data->SetArguments(argc, argv); } -#endif // wxUSE_UNICODE - void wxCmdLineParser::SetCmdLine(const wxString& cmdline) { m_data->SetArguments(cmdline); diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 118e39d1a2..18249416d2 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1528,9 +1528,7 @@ wxDateTime::ParseFormat(const wxString& date, else if ( *input == wxS('-') -#if wxUSE_UNICODE || *input == wxString::FromUTF8("\xe2\x88\x92") -#endif ) minusFound = true; else diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 89f16ac104..1314144c86 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -43,9 +43,7 @@ union Float64Data // ---------------------------------------------------------------------------- wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv) -#if wxUSE_UNICODE : m_conv(conv.Clone()) -#endif // wxUSE_UNICODE { // It is unused in non-Unicode build, so suppress a warning there. wxUnusedVar(conv); @@ -59,19 +57,15 @@ wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv) #endif // wxUSE_APPLE_IEEE } -#if wxUSE_UNICODE void wxDataStreamBase::SetConv( const wxMBConv &conv ) { delete m_conv; m_conv = conv.Clone(); } -#endif wxDataStreamBase::~wxDataStreamBase() { -#if wxUSE_UNICODE delete m_conv; -#endif // wxUSE_UNICODE } // --------------------------------------------------------------------------- @@ -179,18 +173,12 @@ wxString wxDataInputStream::ReadString() const size_t len = Read32(); if ( len > 0 ) { -#if wxUSE_UNICODE wxCharBuffer tmp(len); if ( tmp ) { m_input->Read(tmp.data(), len); ret = m_conv->cMB2WC(tmp.data(), len, nullptr); } -#else - wxStringBuffer buf(ret, len); - if ( buf ) - m_input->Read(buf, len); -#endif } return ret; @@ -585,13 +573,8 @@ void wxDataOutputStream::Write8(wxUint8 i) void wxDataOutputStream::WriteString(const wxString& string) { -#if wxUSE_UNICODE const wxWX2MBbuf buf = string.mb_str(*m_conv); size_t len = buf.length(); -#else - const wxWX2MBbuf buf = string.mb_str(); - size_t len = string.size(); -#endif Write32(len); if (len > 0) m_output->Write(buf, len); diff --git a/src/common/dynlib.cpp b/src/common/dynlib.cpp index 45de5b7ecf..38f9dd9dad 100644 --- a/src/common/dynlib.cpp +++ b/src/common/dynlib.cpp @@ -175,9 +175,7 @@ wxString wxDynamicLibrary::CanonicalizePluginName(const wxString& name, { suffix = wxPlatformInfo::Get().GetPortIdShortName(); } -#if wxUSE_UNICODE suffix << wxT('u'); -#endif #ifdef __WXDEBUG__ suffix << wxT('d'); #endif diff --git a/src/common/event.cpp b/src/common/event.cpp index 516357597c..818a19c0de 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -768,9 +768,7 @@ wxPoint wxMouseEvent::GetLogicalPosition(const wxDC& dc) const // ---------------------------------------------------------------------------- wxKeyEvent::wxKeyEvent(wxEventType type) -#if wxUSE_UNICODE : m_uniChar(WXK_NONE) -#endif { m_eventType = type; m_keyCode = WXK_NONE; diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 8364c56c35..2079d3c10d 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -161,7 +161,6 @@ bool wxFFile::Write(const wxString& s, const wxMBConv& conv) const wxWX2MBbuf buf = s.mb_str(conv); -#if wxUSE_UNICODE const size_t size = buf.length(); if ( !size ) @@ -171,9 +170,6 @@ bool wxFFile::Write(const wxString& s, const wxMBConv& conv) // must fail too to indicate that we can't save the data. return false; } -#else - const size_t size = s.length(); -#endif return Write(buf, size) == size; } diff --git a/src/common/file.cpp b/src/common/file.cpp index a4bc8318be..c9aa71f706 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -365,7 +365,6 @@ bool wxFile::Write(const wxString& s, const wxMBConv& conv) const wxWX2MBbuf buf = s.mb_str(conv); -#if wxUSE_UNICODE const size_t size = buf.length(); if ( !size ) @@ -375,9 +374,6 @@ bool wxFile::Write(const wxString& s, const wxMBConv& conv) // must fail too to indicate that we can't save the data. return false; } -#else - const size_t size = s.length(); -#endif return Write(buf, size) == size; } diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 36810988df..7803f6f402 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -424,17 +424,12 @@ wxFileConfig::wxFileConfig(wxInputStream &inStream, const wxMBConv& conv) } while ( !inStream.Eof() ); -#if wxUSE_UNICODE size_t len; cbuf = conv.cMB2WC((char *)buf.GetData(), buf.GetDataLen() + 1, &len); if ( !len && buf.GetDataLen() ) { wxLogError(_("Failed to read config options.")); } -#else // !wxUSE_UNICODE - // no need for conversion - cbuf = wxCharBuffer::CreateNonOwned((char *)buf.GetData(), buf.GetDataLen()); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // parse the input contents if there is anything to parse if ( cbuf ) @@ -2072,17 +2067,9 @@ static wxString FilterOutEntryName(const wxString& str) for ( const wxChar *pc = str.c_str(); *pc != wxT('\0'); pc++ ) { const wxChar c = *pc; - // we explicitly allow some of "safe" chars and 8bit ASCII characters - // which will probably never have special meaning and with which we can't - // use isalnum() anyhow (in ASCII built, in Unicode it's just fine) - // // NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR // should *not* be quoted - if ( -#if !wxUSE_UNICODE - ((unsigned char)c < 127) && -#endif // ANSI - !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%()"), c) ) + if ( !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%()"), c) ) { strResult += wxT('\\'); } diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index ca5e18971e..77d984eda5 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -734,9 +734,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) // for the compilers which have Unicode version of _getcwd(), call it // directly, for the others call the ANSI version and do the translation -#if !wxUSE_UNICODE - #define cbuf buf -#else // wxUSE_UNICODE bool needsANSI = true; #if !defined(HAVE_WGETCWD) @@ -752,7 +749,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) #endif if ( needsANSI ) -#endif // wxUSE_UNICODE { #if defined(_MSC_VER) || defined(__MINGW32__) ok = _getcwd(cbuf, sz) != nullptr; @@ -760,10 +756,8 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) ok = getcwd(cbuf, sz) != nullptr; #endif // platform - #if wxUSE_UNICODE // finally convert the result to Unicode if needed wxConvFile.MB2WC(buf, cbuf, sz); - #endif // wxUSE_UNICODE } if ( !ok ) @@ -783,7 +777,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) #if defined( __CYGWIN__ ) && defined( __WINDOWS__ ) // another example of DOS/Unix mix (Cygwin) wxString pathUnix = buf; -#if wxUSE_UNICODE #if CYGWIN_VERSION_DLL_MAJOR >= 1007 cygwin_conv_path(CCP_POSIX_TO_WIN_W, pathUnix.mb_str(wxConvFile), buf, sz); #else @@ -791,22 +784,10 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) cygwin_conv_to_full_win32_path(pathUnix.mb_str(wxConvFile), bufA); wxConvFile.MB2WC(buf, bufA, sz); #endif -#else - #if CYGWIN_VERSION_DLL_MAJOR >= 1007 - cygwin_conv_path(CCP_POSIX_TO_WIN_A, pathUnix, buf, sz); - #else - cygwin_conv_to_full_win32_path(pathUnix, buf); - #endif -#endif // wxUSE_UNICODE #endif // __CYGWIN__ } return buf; - -#if !wxUSE_UNICODE - #undef cbuf -#endif - } wxString wxGetCwd() diff --git a/src/common/http.cpp b/src/common/http.cpp index 0d42553eb5..79c4e4b7bb 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -211,14 +211,9 @@ wxHTTP::SetPostText(const wxString& contentType, const wxString& data, const wxMBConv& conv) { -#if wxUSE_UNICODE wxScopedCharBuffer scb = data.mb_str(conv); const size_t len = scb.length(); const char* const buf = scb.data(); -#else // !wxUSE_UNICODE - const size_t len = data.length(); - const char* const buf = data.mb_str(conv); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE if ( !len ) return false; diff --git a/src/common/init.cpp b/src/common/init.cpp index 5fb771b3f3..355007b8bd 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -51,7 +51,7 @@ #endif // wxCrtSetDbgFlag #endif // __WINDOWS__ -#if wxUSE_UNICODE && defined(__WXOSX__) +#if defined(__WXOSX__) #include #endif @@ -132,10 +132,8 @@ static struct InitData InitData() : nInitCount(0) { -#if wxUSE_UNICODE argc = argcOrig = 0; // argv = argvOrig = nullptr; -- not even really needed -#endif // wxUSE_UNICODE } // number of times wxInitialize() was called minus the number of times @@ -145,7 +143,6 @@ static struct InitData // only one of them to actually initialize the library wxAtomicInt nInitCount; -#if wxUSE_UNICODE int argc; // if we receive the command line arguments as ASCII and have to convert @@ -159,7 +156,6 @@ static struct InitData // the latter to be able to free everything correctly int argcOrig; wchar_t **argvOrig; -#endif // wxUSE_UNICODE wxDECLARE_NO_COPY_CLASS(InitData); } gs_initData; @@ -172,8 +168,6 @@ static struct InitData // command line arguments ANSI -> Unicode conversion // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - static void ConvertArgsToUnicode(int argc, char **argv) { gs_initData.argvOrig = new wchar_t *[argc + 1]; @@ -219,8 +213,6 @@ static void FreeConvertedArgs() } } -#endif // wxUSE_UNICODE - // ---------------------------------------------------------------------------- // start up // ---------------------------------------------------------------------------- @@ -228,7 +220,7 @@ static void FreeConvertedArgs() // initialization which is always done (not customizable) before wxApp creation static bool DoCommonPreInit() { -#if wxUSE_UNICODE && defined(__WXOSX__) +#if defined(__WXOSX__) // In OS X and iOS, wchar_t CRT functions convert to char* and fail under // some locales. The safest fix is to set LC_CTYPE to UTF-8 to ensure that // they can handle any input. @@ -238,7 +230,7 @@ static bool DoCommonPreInit() // // See https://stackoverflow.com/questions/11713745/why-does-the-printf-family-of-functions-care-about-locale setlocale(LC_CTYPE, "UTF-8"); -#endif // wxUSE_UNICODE && defined(__WXOSX__) +#endif // defined(__WXOSX__) #if wxUSE_LOG // Reset logging in case we were cleaned up and are being reinitialized. @@ -332,11 +324,7 @@ bool wxEntryStart(int& argc, wxChar **argv) // remember, possibly modified (e.g. due to removal of toolkit-specific // parameters), command line arguments in member variables app->argc = argc; -#if wxUSE_UNICODE app->argv.Init(argc, argv); -#else - app->argv = argv; -#endif wxCallAppCleanup callAppCleanup(app.get()); @@ -365,8 +353,6 @@ bool wxEntryStart(int& argc, wxChar **argv) return true; } -#if wxUSE_UNICODE - // we provide a wxEntryStart() wrapper taking "char *" pointer too bool wxEntryStart(int& argc, char **argv) { @@ -382,8 +368,6 @@ bool wxEntryStart(int& argc, char **argv) return true; } -#endif // wxUSE_UNICODE - // ---------------------------------------------------------------------------- // clean up // ---------------------------------------------------------------------------- @@ -411,9 +395,7 @@ static void DoCommonPostCleanup() // we can't do this in wxApp itself because it doesn't know if argv had // been allocated -#if wxUSE_UNICODE FreeConvertedArgs(); -#endif // wxUSE_UNICODE // use Set(nullptr) and not Get() to avoid creating a message output object on // demand when we just want to delete it @@ -505,8 +487,6 @@ int wxEntryReal(int& argc, wxChar **argv) wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; ) } -#if wxUSE_UNICODE - // as with wxEntryStart, we provide an ANSI wrapper int wxEntry(int& argc, char **argv) { @@ -515,8 +495,6 @@ int wxEntry(int& argc, char **argv) return wxEntry(gs_initData.argc, gs_initData.argv); } -#endif // wxUSE_UNICODE - // ---------------------------------------------------------------------------- // wxInitialize/wxUninitialize // ---------------------------------------------------------------------------- @@ -538,7 +516,6 @@ bool wxInitialize(int& argc, wxChar **argv) return wxEntryStart(argc, argv); } -#if wxUSE_UNICODE bool wxInitialize(int& argc, char **argv) { if ( wxAtomicInc(gs_initData.nInitCount) != 1 ) @@ -549,7 +526,6 @@ bool wxInitialize(int& argc, char **argv) return wxEntryStart(argc, argv); } -#endif // wxUSE_UNICODE void wxUninitialize() { diff --git a/src/common/intl.cpp b/src/common/intl.cpp index f6e6504939..c8d40359de 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -461,7 +461,7 @@ bool wxLocale::Init(int lang, int flags) const char *retloc = lang == wxLANGUAGE_DEFAULT ? wxSetlocale(LC_ALL, "") : info->TrySetLocale(); -#if wxUSE_UNICODE && (defined(__VISUALC__) || defined(__MINGW32__)) +#if defined(__VISUALC__) || defined(__MINGW32__) // VC++ setlocale() (also used by Mingw) can't set locale to languages that // can only be written using Unicode, therefore wxSetlocale() call fails // for such languages but we don't want to report it as an error -- so that @@ -770,12 +770,8 @@ bool wxLocale::AddCatalog(const wxString& szDomain, wxTranslations *t = wxTranslations::Get(); if ( !t ) return false; -#if wxUSE_UNICODE wxUnusedVar(msgIdCharset); return t->AddCatalog(szDomain, msgIdLanguage); -#else - return t->AddCatalog(szDomain, msgIdLanguage, msgIdCharset); -#endif } bool wxLocale::IsLoaded(const wxString& domain) const diff --git a/src/common/ipcbase.cpp b/src/common/ipcbase.cpp index 6712c32d0b..47386efa90 100644 --- a/src/common/ipcbase.cpp +++ b/src/common/ipcbase.cpp @@ -79,7 +79,6 @@ wxString wxConnectionBase::GetTextFromData(const void* data, s = wxString(static_cast(data), size); break; -#if wxUSE_UNICODE // TODO: we should handle both wxIPC_UTF16TEXT and wxIPC_UTF32TEXT here // for inter-platform IPC case wxIPC_UNICODETEXT: @@ -99,7 +98,6 @@ wxString wxConnectionBase::GetTextFromData(const void* data, s = wxString::FromUTF8(static_cast(data), size); break; -#endif // wxUSE_UNICODE default: wxFAIL_MSG( "non-string IPC format in GetTextFromData()" ); diff --git a/src/common/regex.cpp b/src/common/regex.cpp index 63c9b3f633..799651f44b 100644 --- a/src/common/regex.cpp +++ b/src/common/regex.cpp @@ -52,7 +52,7 @@ #if wxUSE_PCRE // Use the same code unit width for PCRE as we use for wxString. -# if !wxUSE_UNICODE || wxUSE_UNICODE_UTF8 +# if wxUSE_UNICODE_UTF8 # define PCRE2_CODE_UNIT_WIDTH 8 typedef char wxRegChar; # elif wxUSE_UNICODE_UTF16 @@ -280,9 +280,7 @@ typedef char wxRegErrorChar; return regexec(preg, string, nmatch, pmatch, eflags); } # endif -# if wxUSE_UNICODE -# define WXREGEX_CONVERT_TO_MB -# endif +# define WXREGEX_CONVERT_TO_MB # define wx_regcomp regcomp # define wx_regfree regfree # define wx_regerror regerror diff --git a/src/common/sstream.cpp b/src/common/sstream.cpp index 47aa953930..a2a9453ee7 100644 --- a/src/common/sstream.cpp +++ b/src/common/sstream.cpp @@ -35,16 +35,10 @@ // TODO: Do we want to include the null char in the stream? If so then // just add +1 to m_len in the ctor wxStringInputStream::wxStringInputStream(const wxString& s) -#if wxUSE_UNICODE // FIXME-UTF8: use wxCharBufferWithLength if we have it : m_str(s), m_buf(s.utf8_str()), m_len(strlen(m_buf)) -#else - : m_str(s), m_buf(s.mb_str()), m_len(s.length()) -#endif { -#if wxUSE_UNICODE wxASSERT_MSG(m_buf.data() != nullptr, wxT("Could not convert string to UTF8!")); -#endif m_pos = 0; } @@ -127,13 +121,10 @@ size_t wxStringInputStream::OnSysRead(void *buffer, size_t size) wxStringOutputStream::wxStringOutputStream(wxString *pString, wxMBConv& conv) : m_conv(conv) -#if wxUSE_UNICODE , m_unconv(0) -#endif // wxUSE_UNICODE { m_str = pString ? pString : &m_strInternal; -#if wxUSE_UNICODE // We can avoid doing the conversion in the common case of using UTF-8 // conversion in UTF-8 build, as it is exactly the same as the string // length anyhow in this case. @@ -143,9 +134,6 @@ wxStringOutputStream::wxStringOutputStream(wxString *pString, wxMBConv& conv) else #endif // wxUSE_UNICODE_UTF8 m_pos = m_conv.FromWChar(nullptr, 0, m_str->wc_str(), m_str->length()); -#else // !wxUSE_UNICODE - m_pos = m_str->length(); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE } // ---------------------------------------------------------------------------- @@ -165,7 +153,6 @@ size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) { const char *p = static_cast(buffer); -#if wxUSE_UNICODE // the part of the string we have here may be incomplete, i.e. it can stop // in the middle of an UTF-8 character and so converting it would fail; if // this is the case, accumulate the part which we failed to convert until @@ -207,10 +194,6 @@ size_t wxStringOutputStream::OnSysWrite(const void *buffer, size_t size) // not update m_pos as m_str hasn't changed return size; } -#else // !wxUSE_UNICODE - // no recoding necessary - m_str->append(p, size); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // update position m_pos += size; diff --git a/src/common/string.cpp b/src/common/string.cpp index c5520bcc93..875a3f37c9 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -188,7 +188,7 @@ static wxStrCacheStatsDumper s_showCacheStats; wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) { -#if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 +#if !wxUSE_UNICODE_UTF8 return os << wxConvWhateverWorks.cWX2MB(str); #else return os << str.AsInternal(); @@ -214,7 +214,7 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str) return os << wxConvWhateverWorks.cWC2MB(str.data()); } -#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#if defined(HAVE_WOSTREAM) wxSTD wostream& operator<<(wxSTD wostream& wos, const wxString& str) { @@ -231,7 +231,7 @@ wxSTD wostream& operator<<(wxSTD wostream& wos, const wxScopedWCharBuffer& str) return wos << str.data(); } -#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#endif // defined(HAVE_WOSTREAM) #endif // wxUSE_STD_IOSTREAM @@ -314,7 +314,6 @@ static inline void DeleteStringFromConversionCache(T& hash, const wxString *s) } } -#if wxUSE_UNICODE // NB: non-STL implementation doesn't compile with "const wxString*" key type, // so we have to use wxString* here and const-cast when used WX_DECLARE_HASH_MAP(wxString*, char*, wxPointerHash, wxPointerEqual, @@ -332,7 +331,6 @@ const char* wxCStrData::AsChar() const return s + m_offset; } -#endif // wxUSE_UNICODE #if !wxUSE_UNICODE_WCHAR WX_DECLARE_HASH_MAP(wxString*, wchar_t*, wxPointerHash, wxPointerEqual, @@ -354,10 +352,8 @@ const wchar_t* wxCStrData::AsWChar() const wxString::~wxString() { -#if wxUSE_UNICODE // FIXME-UTF8: do this only if locale is not UTF8 if wxUSE_UNICODE_UTF8 DeleteStringFromConversionCache(gs_stringsCharCache, this); -#endif #if !wxUSE_UNICODE_WCHAR DeleteStringFromConversionCache(gs_stringsWCharCache, this); #endif @@ -437,7 +433,7 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength, } #endif // wxUSE_UNICODE_UTF8 -#if wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE +#if wxUSE_UNICODE_UTF8 /* static */ wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLength, const wxMBConv& conv) @@ -456,7 +452,7 @@ wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLengt else return SubstrBufFromWC(mbBuf, mbLen); } -#endif // wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE +#endif // wxUSE_UNICODE_UTF8 // This std::string::c_str()-like method returns a wide char pointer to string // contents. In wxUSE_UNICODE_WCHAR case it is trivial as it can simply return @@ -515,8 +511,6 @@ const wchar_t *wxString::AsWChar(const wxMBConv& conv) const // contents: this always requires converting it to the specified encoding in // non-ANSI build except if we need to convert to UTF-8 and this is what we // already use internally. -#if wxUSE_UNICODE - const char *wxString::AsChar(const wxMBConv& conv) const { #if wxUSE_UNICODE_UTF8 @@ -548,8 +542,6 @@ const char *wxString::AsChar(const wxMBConv& conv) const return m_convertedToChar.m_str; } -#endif // wxUSE_UNICODE - // shrink to minimal size (releasing extra memory) bool wxString::Shrink() { @@ -1010,40 +1002,28 @@ size_t wxString::find_last_not_of(wxUniChar ch, size_t nStart) const } // the functions above were implemented for wchar_t* arguments in Unicode -// build and char* in ANSI build; below are implementations for the other -// version: -#if wxUSE_UNICODE - #define wxOtherCharType char - #define STRCONV (const wxChar*)wxConvLibc.cMB2WC -#else - #define wxOtherCharType wchar_t - #define STRCONV (const wxChar*)wxConvLibc.cWC2MB -#endif +// build; below are implementations for the char* arguments +size_t wxString::find_first_of(const char* sz, size_t nStart) const + { return find_first_of(wxConvLibc.cMB2WC(sz), nStart); } -size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart) const - { return find_first_of(STRCONV(sz), nStart); } - -size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart, +size_t wxString::find_first_of(const char* sz, size_t nStart, size_t n) const - { return find_first_of(STRCONV(sz, n, nullptr), nStart, n); } -size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart) const - { return find_last_of(STRCONV(sz), nStart); } -size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart, + { return find_first_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); } +size_t wxString::find_last_of(const char* sz, size_t nStart) const + { return find_last_of(wxConvLibc.cMB2WC(sz), nStart); } +size_t wxString::find_last_of(const char* sz, size_t nStart, size_t n) const - { return find_last_of(STRCONV(sz, n, nullptr), nStart, n); } -size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart) const - { return find_first_not_of(STRCONV(sz), nStart); } -size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart, + { return find_last_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); } +size_t wxString::find_first_not_of(const char* sz, size_t nStart) const + { return find_first_not_of(wxConvLibc.cMB2WC(sz), nStart); } +size_t wxString::find_first_not_of(const char* sz, size_t nStart, size_t n) const - { return find_first_not_of(STRCONV(sz, n, nullptr), nStart, n); } -size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart) const - { return find_last_not_of(STRCONV(sz), nStart); } -size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart, + { return find_first_not_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); } +size_t wxString::find_last_not_of(const char* sz, size_t nStart) const + { return find_last_not_of(wxConvLibc.cMB2WC(sz), nStart); } +size_t wxString::find_last_not_of(const char* sz, size_t nStart, size_t n) const - { return find_last_not_of(STRCONV(sz, n, nullptr), nStart, n); } - -#undef wxOtherCharType -#undef STRCONV + { return find_last_not_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); } #endif // !wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 @@ -1137,8 +1117,6 @@ int wxString::CmpNoCase(const wxString& s) const } -#if wxUSE_UNICODE - wxString wxString::FromAscii(const char *ascii, size_t len) { wxString res; @@ -1201,8 +1179,6 @@ const wxScopedCharBuffer wxString::ToAscii(char replaceWith) const return buffer; } -#endif // wxUSE_UNICODE - // extract string of length nCount starting at nFirst wxString wxString::Mid(size_t nFirst, size_t nCount) const { @@ -1735,7 +1711,7 @@ bool wxString::ToCLong(long *pVal, int base) const wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) +#if wxUSE_UNICODE_UTF8 && defined(wxHAS_XLOCALE_SUPPORT) long val = wxStrtol_lA(start, &end, base, wxCLocale); #else long val = wxStrtol_l(start, &end, base, wxCLocale); @@ -1748,7 +1724,7 @@ bool wxString::ToCULong(unsigned long *pVal, int base) const wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") ); WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) +#if wxUSE_UNICODE_UTF8 && defined(wxHAS_XLOCALE_SUPPORT) unsigned long val = wxStrtoul_lA(start, &end, base, wxCLocale); #else unsigned long val = wxStrtoul_l(start, &end, base, wxCLocale); @@ -1759,7 +1735,7 @@ bool wxString::ToCULong(unsigned long *pVal, int base) const bool wxString::ToCDouble(double *pVal) const { WX_STRING_TO_X_TYPE_START -#if (wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE) && defined(wxHAS_XLOCALE_SUPPORT) +#if wxUSE_UNICODE_UTF8 && defined(wxHAS_XLOCALE_SUPPORT) double val = wxStrtod_lA(start, &end, wxCLocale); #else double val = wxStrtod_l(start, &end, wxCLocale); diff --git a/src/common/stringops.cpp b/src/common/stringops.cpp index 98a9e5e14c..3d91804318 100644 --- a/src/common/stringops.cpp +++ b/src/common/stringops.cpp @@ -26,7 +26,7 @@ // implementation // =========================================================================== -#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE +#if wxUSE_UNICODE_WCHAR #if wxUSE_UNICODE_UTF16 @@ -88,7 +88,7 @@ wxWxCharBuffer wxStringOperationsWchar::EncodeNChars(size_t n, const wxUniChar& #endif // wxUSE_UNICODE_UTF16 -#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE +#endif // wxUSE_UNICODE_WCHAR #if wxUSE_UNICODE_UTF8 diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index dc5e8ed9b6..5c16483714 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -493,27 +493,6 @@ class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase }; #endif // wxUSE_UNICODE_UTF8 -#if !wxUSE_UNICODE // FIXME-UTF8: remove -class wxPrintfFormatConverterANSI : public wxFormatConverterBase -{ - virtual void HandleString(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 's'; - outSize = Size_Default; - } - - virtual void HandleChar(CharType WXUNUSED(conv), - SizeModifier WXUNUSED(size), - CharType& outConv, SizeModifier& outSize) - { - outConv = 'c'; - outSize = Size_Default; - } -}; -#endif // ANSI - #ifndef __WINDOWS__ /* @@ -605,17 +584,13 @@ const char* wxFormatString::InputAsChar() const char* wxFormatString::AsChar() { if ( !m_convertedChar ) -#if !wxUSE_UNICODE // FIXME-UTF8: remove this - m_convertedChar = wxPrintfFormatConverterANSI().Convert(InputAsChar()); -#else m_convertedChar = wxPrintfFormatConverterUtf8().Convert(InputAsChar()); -#endif return m_convertedChar.data(); } #endif // !wxUSE_UNICODE_WCHAR -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#if !wxUSE_UTF8_LOCALE_ONLY const wchar_t* wxFormatString::InputAsWChar() { if ( m_wchar ) @@ -655,7 +630,7 @@ const wchar_t* wxFormatString::AsWChar() return m_convertedWChar.data(); } -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#endif // !wxUSE_UTF8_LOCALE_ONLY wxString wxFormatString::InputAsString() const { diff --git a/src/common/tarstrm.cpp b/src/common/tarstrm.cpp index 688241504a..73d91683a9 100644 --- a/src/common/tarstrm.cpp +++ b/src/common/tarstrm.cpp @@ -274,7 +274,6 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv) { bool badconv = false; -#if wxUSE_UNICODE wxCharBuffer nameBuf = name.mb_str(conv); // if the conversion fails make an approximation @@ -291,10 +290,6 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv) } const char *mbName = nameBuf; -#else - const char *mbName = name.c_str(); - (void)conv; -#endif bool fits; bool notGoingToFit = false; @@ -1434,16 +1429,8 @@ void wxTarOutputStream::SetExtendedHeader(const wxString& key, const wxString& value) { if (m_pax) { -#if wxUSE_UNICODE const wxCharBuffer utf_key = key.utf8_str(); const wxCharBuffer utf_value = value.utf8_str(); -#else - const wxWX2WCbuf wide_key = key.wc_str(GetConv()); - const wxCharBuffer utf_key = wxConvUTF8.cWC2MB(wide_key); - - const wxWX2WCbuf wide_value = value.wc_str(GetConv()); - const wxCharBuffer utf_value = wxConvUTF8.cWC2MB(wide_value); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // a small buffer to format the length field in char buf[32]; diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index 7c73c1080e..051c076add 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -1142,14 +1142,11 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) break; default: -#if wxUSE_UNICODE if ( event.GetUnicodeKey() ) { ch = event.GetUnicodeKey(); } - else -#endif - if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) ) + else if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) ) { // FIXME this is not going to work for non letters... if ( !event.ShiftDown() ) diff --git a/src/common/textentrycmn.cpp b/src/common/textentrycmn.cpp index a9c1d8b714..93c322ad30 100644 --- a/src/common/textentrycmn.cpp +++ b/src/common/textentrycmn.cpp @@ -313,9 +313,7 @@ bool wxTextEntryBase::CanPaste() const #if wxUSE_CLIPBOARD // check if there is any text on the clipboard if ( wxTheClipboard->IsSupported(wxDF_TEXT) -#if wxUSE_UNICODE || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) -#endif // wxUSE_UNICODE ) { return true; diff --git a/src/common/tokenzr.cpp b/src/common/tokenzr.cpp index 64efbf1211..18e630950f 100644 --- a/src/common/tokenzr.cpp +++ b/src/common/tokenzr.cpp @@ -126,11 +126,7 @@ void wxStringTokenizer::SetString(const wxString& str, } } -#if wxUSE_UNICODE // FIXME-UTF8: only wc_str() m_delims = delims.wc_str(); -#else - m_delims = delims.mb_str(); -#endif m_delimsLen = delims.length(); m_mode = mode; diff --git a/src/common/translation.cpp b/src/common/translation.cpp index a701338720..ce4dbd869c 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -79,13 +79,6 @@ const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495; namespace { -#if !wxUSE_UNICODE -// We need to keep track of (char*) msgids in non-Unicode legacy builds. Instead -// of making the public wxMsgCatalog and wxTranslationsLoader APIs ugly, we -// store them in this global map. -wxStringToStringHashMap gs_msgIdCharset; -#endif - // ---------------------------------------------------------------------------- // Platform specific helpers // ---------------------------------------------------------------------------- @@ -1132,39 +1125,19 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, if ( !m_charset.empty() ) { -#if !wxUSE_UNICODE && wxUSE_FONTMAP - // determine if we need any conversion at all - wxFontEncoding encCat = wxFontMapperBase::GetEncodingFromName(m_charset); - if ( encCat != wxLocale::GetSystemEncoding() ) -#endif - { - inputConv = new wxCSConv(m_charset); + inputConv = new wxCSConv(m_charset); - // As we allocated it ourselves, we need to delete it, so ensure - // this happens. - inputConvPtr.reset(inputConv); - } + // As we allocated it ourselves, we need to delete it, so ensure + // this happens. + inputConvPtr.reset(inputConv); } - else // no need or not possible to convert the encoding + else // no need to convert the encoding { -#if wxUSE_UNICODE // we must somehow convert the narrow strings in the message catalog to // wide strings, so use the default conversion if we have no charset inputConv = wxConvCurrent; -#endif } -#if !wxUSE_UNICODE - wxString msgIdCharset = gs_msgIdCharset[domain]; - - // conversion to apply to msgid strings before looking them up: we only - // need it if the msgids are neither in 7 bit ASCII nor in the same - // encoding as the catalog - wxScopedPtr sourceConv; - if ( !msgIdCharset.empty() && (msgIdCharset != m_charset) ) - sourceConv.reset(new wxCSConv(msgIdCharset)); -#endif // !wxUSE_UNICODE - for (size_t32 i = 0; i < m_numStrings; i++) { const char *data = StringAtOfs(m_pOrigTable, i); @@ -1172,15 +1145,7 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, return false; // may happen for invalid MO files wxString msgid; -#if wxUSE_UNICODE msgid = wxString(data, *inputConv); -#else // ASCII - if ( inputConv && sourceConv ) - msgid = wxString(inputConv->cMB2WC(data), *sourceConv); - else - msgid = data; -#endif // wxUSE_UNICODE - data = StringAtOfs(m_pTransTable, i); if (!data) return false; // may happen for invalid MO files @@ -1193,15 +1158,7 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, const char * const str = data + offset; wxString msgstr; -#if wxUSE_UNICODE msgstr = wxString(str, *inputConv); -#else - if ( inputConv ) - msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI); - else - msgstr = str; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE - if ( !msgstr.empty() ) { hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr; @@ -1226,23 +1183,6 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash, // wxMsgCatalog class // ---------------------------------------------------------------------------- -#if !wxUSE_UNICODE -wxMsgCatalog::~wxMsgCatalog() -{ - if ( m_conv ) - { - if ( wxConvUI == m_conv ) - { - // we only change wxConvUI if it points to wxConvLocal so we reset - // it back to it too - wxConvUI = &wxConvLocal; - } - - delete m_conv; - } -} -#endif // !wxUSE_UNICODE - /* static */ wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename, const wxString& domain) @@ -1415,16 +1355,6 @@ bool wxTranslations::AddStdCatalog() return false; } -#if !wxUSE_UNICODE -bool wxTranslations::AddCatalog(const wxString& domain, - wxLanguage msgIdLanguage, - const wxString& msgIdCharset) -{ - gs_msgIdCharset[domain] = msgIdCharset; - return AddCatalog(domain, msgIdLanguage); -} -#endif // !wxUSE_UNICODE - bool wxTranslations::AddCatalog(const wxString& domain, wxLanguage msgIdLanguage) { diff --git a/src/common/txtstrm.cpp b/src/common/txtstrm.cpp index 1aa666e6df..b002c51437 100644 --- a/src/common/txtstrm.cpp +++ b/src/common/txtstrm.cpp @@ -26,7 +26,6 @@ // wxTextInputStream // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE wxTextInputStream::wxTextInputStream(wxInputStream &s, const wxString &sep, const wxMBConv& conv) @@ -39,22 +38,10 @@ wxTextInputStream::wxTextInputStream(wxInputStream &s, m_lastWChar = 0; #endif // SIZEOF_WCHAR_T == 2 } -#else -wxTextInputStream::wxTextInputStream(wxInputStream &s, const wxString &sep) - : m_input(s), m_separators(sep) -{ - m_validBegin = - m_validEnd = 0; - - m_lastBytes[0] = 0; -} -#endif wxTextInputStream::~wxTextInputStream() { -#if wxUSE_UNICODE delete m_conv; -#endif // wxUSE_UNICODE } void wxTextInputStream::UngetLast() @@ -70,7 +57,6 @@ void wxTextInputStream::UngetLast() wxChar wxTextInputStream::GetChar() { -#if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 // Return the already raed character remaining from the last call to this // function, if any. @@ -169,20 +155,6 @@ wxChar wxTextInputStream::GetChar() m_validEnd = sizeof(m_lastBytes); return 0; -#else - m_lastBytes[0] = m_input.GetC(); - - if(m_input.LastRead() <= 0) - { - m_validEnd = 0; - return 0; - } - - m_validEnd = 1; - - return m_lastBytes[0]; -#endif - } wxChar wxTextInputStream::NextNonSeparators() @@ -377,7 +349,7 @@ wxTextInputStream& wxTextInputStream::operator>>(char& c) return *this; } -#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE +#if wxWCHAR_T_IS_REAL_TYPE wxTextInputStream& wxTextInputStream::operator>>(wchar_t& wc) { @@ -386,7 +358,7 @@ wxTextInputStream& wxTextInputStream::operator>>(wchar_t& wc) return *this; } -#endif // wxUSE_UNICODE +#endif // wxWCHAR_T_IS_REAL_TYPE wxTextInputStream& wxTextInputStream::operator>>(wxInt16& i) { @@ -438,15 +410,10 @@ wxTextInputStream& wxTextInputStream::operator>>(float& f) -#if wxUSE_UNICODE wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode, const wxMBConv& conv) : m_output(s), m_conv(conv.Clone()) -#else -wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode) - : m_output(s) -#endif { m_mode = mode; if (m_mode == wxEOL_NATIVE) @@ -458,16 +425,14 @@ wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode) #endif } -#if wxUSE_UNICODE && SIZEOF_WCHAR_T == 2 +#if SIZEOF_WCHAR_T == 2 m_lastWChar = 0; #endif // SIZEOF_WCHAR_T == 2 } wxTextOutputStream::~wxTextOutputStream() { -#if wxUSE_UNICODE delete m_conv; -#endif // wxUSE_UNICODE } void wxTextOutputStream::SetMode(wxEOL mode) @@ -555,18 +520,13 @@ void wxTextOutputStream::WriteString(const wxString& string) out << c; } -#if wxUSE_UNICODE // FIXME-UTF8: use wxCharBufferWithLength if/when we have it wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len); m_output.Write(buffer, len); -#else - m_output.Write(out.c_str(), out.length() ); -#endif } wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c) { -#if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 wxCharBuffer buffer; size_t len; @@ -627,15 +587,11 @@ wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c) #else // SIZEOF_WCHAR_T == 4 WriteString( wxString(&c, *m_conv, 1) ); #endif // SIZEOF_WCHAR_T == 2 or 4 -#else - WriteString( wxString(&c, wxConvLocal, 1) ); -#endif return *this; } void wxTextOutputStream::Flush() { -#if wxUSE_UNICODE const size_t len = m_conv->FromWChar(nullptr, 0, L"", 1); if ( len > m_conv->GetMBNulLen() ) { @@ -643,7 +599,6 @@ void wxTextOutputStream::Flush() m_conv->FromWChar(buf.data(), len, L"", 1); m_output.Write(buf, len - m_conv->GetMBNulLen()); } -#endif // wxUSE_UNICODE } wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string) @@ -659,7 +614,7 @@ wxTextOutputStream& wxTextOutputStream::operator<<(char c) return *this; } -#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE +#if wxWCHAR_T_IS_REAL_TYPE wxTextOutputStream& wxTextOutputStream::operator<<(wchar_t wc) { @@ -668,7 +623,7 @@ wxTextOutputStream& wxTextOutputStream::operator<<(wchar_t wc) return *this; } -#endif // wxUSE_UNICODE +#endif // wxWCHAR_T_IS_REAL_TYPE wxTextOutputStream& wxTextOutputStream::operator<<(wxInt16 c) { diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 1786b9bf66..7228379d85 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1391,10 +1391,8 @@ wxVersionInfo wxGetLibraryVersionInfo() wxRELEASE_NUMBER, #if wxUSE_UNICODE_UTF8 "UTF-8", -#elif wxUSE_UNICODE - "wchar_t", #else - "none", + "wchar_t", #endif wxDEBUG_LEVEL, #if !wxUSE_REPRODUCIBLE_BUILD diff --git a/src/common/valnum.cpp b/src/common/valnum.cpp index cc8744a5a5..dc09279201 100644 --- a/src/common/valnum.cpp +++ b/src/common/valnum.cpp @@ -150,7 +150,6 @@ void wxNumValidatorBase::OnChar(wxKeyEvent& event) if ( !m_validatorWindow ) return; -#if wxUSE_UNICODE const int ch = event.GetUnicodeKey(); if ( ch == WXK_NONE ) { @@ -158,14 +157,6 @@ void wxNumValidatorBase::OnChar(wxKeyEvent& event) // arrow or function key, we never filter those. return; } -#else // !wxUSE_UNICODE - const int ch = event.GetKeyCode(); - if ( ch > WXK_DELETE ) - { - // Not a character either. - return; - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE if ( ch < WXK_SPACE || ch == WXK_DELETE ) { diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index e6bf1986c9..7a94a1fc96 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -280,14 +280,8 @@ void wxTextValidator::OnChar(wxKeyEvent& event) if (!m_validatorWindow) return; -#if wxUSE_UNICODE // We only filter normal, printable characters. int keyCode = event.GetUnicodeKey(); -#else // !wxUSE_UNICODE - int keyCode = event.GetKeyCode(); - if ( keyCode > WXK_START ) - return; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // we don't filter special keys and delete if (keyCode < WXK_SPACE || keyCode == WXK_DELETE) diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 9177d245c8..ab8ae524a7 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -448,8 +448,6 @@ int wxDoSprintfUtf8(char *str, const char *format, ...) } #endif // wxUSE_UNICODE_UTF8 -#if wxUSE_UNICODE - #if !wxUSE_UTF8_LOCALE_ONLY int wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...) { @@ -476,8 +474,6 @@ int wxDoSprintfUtf8(wchar_t *str, const char *format, ...) } #endif // wxUSE_UNICODE_UTF8 -#endif // wxUSE_UNICODE - #if !wxUSE_UTF8_LOCALE_ONLY int wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...) { @@ -504,8 +500,6 @@ int wxDoSnprintfUtf8(char *str, size_t size, const char *format, ...) } #endif // wxUSE_UNICODE_UTF8 -#if wxUSE_UNICODE - #if !wxUSE_UTF8_LOCALE_ONLY int wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...) { @@ -532,15 +526,11 @@ int wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...) } #endif // wxUSE_UNICODE_UTF8 -#endif // wxUSE_UNICODE - #ifdef HAVE_BROKEN_VSNPRINTF_DECL #define vsnprintf wx_fixed_vsnprintf #endif -#if wxUSE_UNICODE - namespace { @@ -593,7 +583,6 @@ static size_t PrintfViaString(T *out, size_t outsize, return ConvertStringToBuf(s, out, outsize); } -#endif // wxUSE_UNICODE int wxVsprintf(char *str, const wxString& format, va_list argptr) { @@ -605,15 +594,10 @@ int wxVsprintf(char *str, const wxString& format, va_list argptr) return wxCRT_VsprintfA(str, format.wx_str(), argptr); else #endif - #if wxUSE_UNICODE return PrintfViaString(str, wxNO_LEN, format, argptr); - #else - return wxCRT_VsprintfA(str, format.mb_str(), argptr); - #endif #endif } -#if wxUSE_UNICODE int wxVsprintf(wchar_t *str, const wxString& format, va_list argptr) { #if wxUSE_UNICODE_WCHAR @@ -627,7 +611,6 @@ int wxVsprintf(wchar_t *str, const wxString& format, va_list argptr) return PrintfViaString(str, wxNO_LEN, format, argptr); #endif // wxUSE_UNICODE_UTF8 } -#endif // wxUSE_UNICODE int wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr) { @@ -640,16 +623,12 @@ int wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr) rv = wxCRT_VsnprintfA(str, size, format.wx_str(), argptr); else #endif - #if wxUSE_UNICODE { // NB: if this code is called, then wxString::PrintV() would use the // wchar_t* version of wxVsnprintf(), so it's safe to use PrintV() // from here rv = PrintfViaString(str, size, format, argptr); } - #else - rv = wxCRT_VsnprintfA(str, size, format.mb_str(), argptr); - #endif #endif // VsnprintfTestCase reveals that glibc's implementation of vswprintf @@ -659,7 +638,6 @@ int wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr) return rv; } -#if wxUSE_UNICODE int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr) { int rv; @@ -687,8 +665,6 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt return rv; } -#endif // wxUSE_UNICODE - // ---------------------------------------------------------------------------- // ctype.h stuff (currently unused) @@ -1173,13 +1149,9 @@ int wxFputs(const wxString& s, FILE *stream) int wxFputc(const wxUniChar& c, FILE *stream) { -#if !wxUSE_UNICODE // FIXME-UTF8: temporary, remove this with ANSI build - return wxCRT_FputcA((char)c, stream); -#else CALL_ANSI_OR_UNICODE(return, wxCRT_FputsA(c.AsUTF8(), stream), wxCRT_FputcW((wchar_t)c, stream)); -#endif } #ifdef wxCRT_PerrorA diff --git a/src/common/xtixml.cpp b/src/common/xtixml.cpp index c8b22b1d6d..029f5bd153 100644 --- a/src/common/xtixml.cpp +++ b/src/common/xtixml.cpp @@ -294,13 +294,8 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *ca createParamOids = new int[classInfo->GetCreateParamCount() ]; createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ]; -#if wxUSE_UNICODE typedef map PropertyNodes; typedef vector PropertyNames; -#else - typedef map PropertyNodes; - typedef vector PropertyNames; -#endif PropertyNodes propertyNodes; PropertyNames propertyNames; diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp index d60ddba639..b6118daa72 100644 --- a/src/common/zipstrm.cpp +++ b/src/common/zipstrm.cpp @@ -89,18 +89,9 @@ static wxString ReadString(wxInputStream& stream, wxUint16 len, wxMBConv& conv) if (len == 0) return wxEmptyString; -#if wxUSE_UNICODE wxCharBuffer buf(len); stream.Read(buf.data(), len); wxString str(buf, conv); -#else - wxString str; - (void)conv; - { - wxStringBuffer buf(str, len); - stream.Read(buf, len); - } -#endif return str; } diff --git a/src/dfb/app.cpp b/src/dfb/app.cpp index d711257d98..41dc5f295f 100644 --- a/src/dfb/app.cpp +++ b/src/dfb/app.cpp @@ -41,7 +41,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // is just a temporary fix to make wxDFB compile in Unicode // build, the real fix is to change Initialize()'s signature // to use char* on Unix. -#if wxUSE_UNICODE // DirectFBInit() wants UTF-8, not wchar_t, so convert int i; char **argvDFB = new char *[argc + 1]; @@ -80,20 +79,9 @@ bool wxApp::Initialize(int& argc, wxChar **argv) delete [] argvDFB; -#else // ANSI - - if ( !wxDfbCheckReturn(DirectFBInit(&argc, &argv)) ) - return false; - -#endif // Unicode/ANSI - // update internal arg[cv] as DFB may have removed processed options: this->argc = argc; -#if wxUSE_UNICODE this->argv.Init(argc, argv); -#else - this->argv = argv; -#endif if ( !wxIDirectFB::Get() ) return false; diff --git a/src/dfb/window.cpp b/src/dfb/window.cpp index 6dceeb0028..84507647d0 100644 --- a/src/dfb/window.cpp +++ b/src/dfb/window.cpp @@ -961,21 +961,7 @@ static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id, switch ( DFB_KEY_TYPE(key_symbol) ) { case DIKT_UNICODE: -#if wxUSE_UNICODE return key_symbol; -#else - if ( key_symbol < 128 ) - return key_symbol; - else - { - wchar_t chr = key_symbol; - wxCharBuffer buf(wxConvUI->cWC2MB(&chr, 1, nullptr)); - if ( buf ) - return *buf; // may be 0 if failed - else - return 0; - } -#endif default: return GetTranslatedKeyCode(key_id); @@ -1002,9 +988,7 @@ void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent& event_) event.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e)); event.m_rawCode = e.key_code; event.m_keyCode = GetTranslatedKeyCode(e.key_id); -#if wxUSE_UNICODE event.m_uniChar = e.key_symbol; -#endif event.m_shiftDown = ( e.modifiers & DIMM_SHIFT ) != 0; event.m_controlDown = ( e.modifiers & DIMM_CONTROL ) != 0; event.m_altDown = ( e.modifiers & DIMM_ALT ) != 0; diff --git a/src/generic/aboutdlgg.cpp b/src/generic/aboutdlgg.cpp index bb0cd240a6..e7c9a2bef7 100644 --- a/src/generic/aboutdlgg.cpp +++ b/src/generic/aboutdlgg.cpp @@ -96,11 +96,9 @@ wxString wxAboutDialogInfo::GetCopyrightToDisplay() const { wxString ret = m_copyright; -#if wxUSE_UNICODE const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9"); ret.Replace("(c)", copyrightSign); ret.Replace("(C)", copyrightSign); -#endif // wxUSE_UNICODE return ret; } diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index 8148bcab84..63d758ed70 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -400,13 +400,8 @@ bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event) if ((ctrl || alt) && !(ctrl && alt)) return false; -#if wxUSE_UNICODE if ( static_cast(event.GetUnicodeKey()) == WXK_NONE ) return false; -#else - if ( event.GetKeyCode() > WXK_START ) - return false; -#endif return true; } @@ -584,12 +579,10 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event) bool isPrintable; -#if wxUSE_UNICODE ch = event.GetUnicodeKey(); if ( ch != WXK_NONE ) isPrintable = true; else -#endif // wxUSE_UNICODE { ch = event.GetKeyCode(); isPrintable = ch >= WXK_SPACE && ch < WXK_START; diff --git a/src/generic/htmllbox.cpp b/src/generic/htmllbox.cpp index 28e9b65291..649b162e89 100644 --- a/src/generic/htmllbox.cpp +++ b/src/generic/htmllbox.cpp @@ -303,10 +303,6 @@ wxHtmlCell* wxHtmlListBox::CreateCellForItem(size_t n) const self->m_htmlParser = new wxHtmlWinParser(self); m_htmlParser->SetDC(new wxClientDC(self)); m_htmlParser->SetFS(&self->m_filesystem); -#if !wxUSE_UNICODE - if (GetFont().IsOk()) - m_htmlParser->SetInputEncoding(GetFont().GetEncoding()); -#endif // use system's default GUI font by default: m_htmlParser->SetStandardFonts(); } diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index e6d89233d8..b54d0967e9 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -497,11 +497,8 @@ wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTi wxDefaultSize, wxTE_MULTILINE | wxHSCROLL | - // needed for Win32 to avoid 65Kb limit but it doesn't work well - // when using RichEdit 2.0 which we always do in the Unicode build -#if !wxUSE_UNICODE + // needed for Win32 to avoid 65Kb limit wxTE_RICH | -#endif // !wxUSE_UNICODE wxTE_READONLY); #if wxUSE_MENUS diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index b7549cc739..f4702b3afd 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -426,11 +426,7 @@ void wxVListBoxComboPopup::OnComboCharEvent( wxKeyEvent& event ) { // unlike in OnComboKeyEvent, wxEVT_CHAR contains meaningful // printable character information, so pass it -#if wxUSE_UNICODE const wxChar charcode = event.GetUnicodeKey(); -#else - const wxChar charcode = (wxChar)event.GetKeyCode(); -#endif if ( !HandleKey(event.GetKeyCode(), true, charcode) ) event.Skip(); @@ -508,11 +504,7 @@ void wxVListBoxComboPopup::OnChar(wxKeyEvent& event) { // Process partial completion key codes here, but not the arrow keys as // the base class will do that for us -#if wxUSE_UNICODE const wxChar charcode = event.GetUnicodeKey(); -#else - const wxChar charcode = (wxChar)event.GetKeyCode(); -#endif if ( wxIsprint(charcode) ) { OnComboCharEvent(event); diff --git a/src/gtk/aboutdlg.cpp b/src/gtk/aboutdlg.cpp index 03d56d7d80..95fe64780e 100644 --- a/src/gtk/aboutdlg.cpp +++ b/src/gtk/aboutdlg.cpp @@ -52,19 +52,12 @@ public: for ( size_t n = 0; n < m_count; n++ ) { -#if wxUSE_UNICODE // notice that there is no need to copy the string pointer here // because this class is used only as a temporary and during its // existence the pointer persists in wxString which uses it either // for internal representation (in wxUSE_UNICODE_UTF8 case) or as // cached m_convertedToChar (in wxUSE_UNICODE_WCHAR case) m_strings[n] = wxGTK_CONV_SYS(a[n]); -#else // !wxUSE_UNICODE - // and in ANSI build we can simply borrow the pointer from - // wxCharBuffer (which owns it in this case) instead of copying it - // but we then become responsible for freeing it - m_strings[n] = wxGTK_CONV_SYS(a[n]).release(); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE } // array must be null-terminated @@ -75,11 +68,6 @@ public: ~GtkArray() { -#if !wxUSE_UNICODE - for ( size_t n = 0; n < m_count; n++ ) - free(const_cast(m_strings[n])); -#endif - delete [] m_strings; } diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 550cf35242..7d1855860c 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -474,7 +474,6 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) bool init_result; -#if wxUSE_UNICODE int i; // gtk_init() wants UTF-8, not wchar_t, so convert @@ -530,19 +529,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) } delete [] argvGTK; -#else // !wxUSE_UNICODE - // gtk_init() shouldn't actually change argv_ itself (just its contents) so - // it's ok to pass pointer to it - init_result = gtk_init_check( &argc_, &argv_ ); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE // update internal arg[cv] as GTK+ may have removed processed options: this->argc = argc_; -#if wxUSE_UNICODE this->argv.Init(argc_, argv_); -#else - this->argv = argv_; -#endif if ( !init_result ) { diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index a848627874..099b145862 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -44,9 +44,7 @@ typedef wxScopedArray wxDataFormatArray; static GdkAtom g_targetsAtom = nullptr; static GdkAtom g_timestampAtom = nullptr; -#if wxUSE_UNICODE extern GdkAtom g_altTextAtom; -#endif // the trace mask we use with wxLogTrace() - call // wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here @@ -316,7 +314,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), // use UTF8_STRING format if requested in Unicode build but just plain // STRING one in ANSI or if explicitly asked in Unicode -#if wxUSE_UNICODE if (format == wxDF_UNICODETEXT) { gtk_selection_data_set_text( @@ -325,7 +322,6 @@ selection_handler( GtkWidget *WXUNUSED(widget), size ); } else -#endif // wxUSE_UNICODE { gtk_selection_data_set( selection_data, @@ -689,13 +685,11 @@ bool wxClipboard::IsSupported( const wxDataFormat& format ) if ( DoIsSupported(format) ) return true; -#if wxUSE_UNICODE if ( format == wxDF_UNICODETEXT ) { // also with plain STRING format return DoIsSupported(g_altTextAtom); } -#endif // wxUSE_UNICODE return false; } @@ -744,11 +738,7 @@ bool wxClipboard::GetData( wxDataObject& data ) tokens is given (that is more than 1 for non-ASCII characters) (tested with Gnumeric-1.6.1 and OpenOffice.org-2.0.2) */ -#if wxUSE_UNICODE if ( format != wxDF_UNICODETEXT || data.GetDataSize(format) > 0 ) -#else // !UNICODE - if ( format != wxDF_TEXT || data.GetDataSize(format) > 1 ) -#endif // UNICODE / !UNICODE { wxCHECK_MSG( m_formatSupported, false, wxT("error retrieving data from clipboard") ); diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index dea9b68866..7589bca170 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -76,18 +76,10 @@ void wxDataFormat::SetType( wxDataFormatId type ) m_type = type; -#if wxUSE_UNICODE if (m_type == wxDF_UNICODETEXT) m_format = g_textAtom; else if (m_type == wxDF_TEXT) m_format = g_altTextAtom; -#else // !wxUSE_UNICODE - // notice that we don't map wxDF_UNICODETEXT to g_textAtom here, this - // would lead the code elsewhere to treat data objects with this format as - // containing UTF-8 data which is not true - if (m_type == wxDF_TEXT) - m_format = g_textAtom; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE else if (m_type == wxDF_BITMAP) m_format = g_pngAtom; @@ -120,11 +112,7 @@ void wxDataFormat::SetId( NativeFormat format ) m_format = format; if (m_format == g_textAtom) -#if wxUSE_UNICODE m_type = wxDF_UNICODETEXT; -#else - m_type = wxDF_TEXT; -#endif else if (m_format == g_altTextAtom) m_type = wxDF_TEXT; @@ -159,12 +147,8 @@ void wxDataFormat::PrepareFormats() // here (with whom?) if (!g_textAtom) { -#if wxUSE_UNICODE g_textAtom = gdk_atom_intern( "UTF8_STRING", FALSE ); g_altTextAtom = gdk_atom_intern( "STRING", FALSE ); -#else - g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE ); -#endif } if (!g_pngAtom) g_pngAtom = gdk_atom_intern( "image/png", FALSE ); @@ -217,8 +201,6 @@ bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) // wxTextDataObject // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir)) const @@ -227,8 +209,6 @@ wxTextDataObject::GetAllFormats(wxDataFormat *formats, *formats = g_altTextAtom; } -#endif // wxUSE_UNICODE - // ---------------------------------------------------------------------------- // wxFileDataObject // ---------------------------------------------------------------------------- diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 28d70cabbb..7d6f9a81e3 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -2876,19 +2876,7 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label, SetMode(mode); SetAlignment(align); -#if !wxUSE_UNICODE - // We can't initialize the renderer just yet because we don't have the - // pointer to the column that uses this renderer yet and so attempt to - // dereference GetOwner() to get the font that is used as a source of - // encoding in multibyte-to-Unicode conversion in GTKSetLabel() in - // non-Unicode builds would crash. So simply remember to do it later. - if ( !m_label.empty() ) - m_needsToSetLabel = true; - else -#endif // !wxUSE_UNICODE - { - GTKSetLabel(); - } + GTKSetLabel(); } wxDataViewProgressRenderer::~wxDataViewProgressRenderer() @@ -2909,19 +2897,10 @@ void wxDataViewProgressRenderer::GTKSetLabel() g_value_set_string( gvalue, buf); g_object_set_property( G_OBJECT(m_renderer), "text", gvalue ); - -#if !wxUSE_UNICODE - m_needsToSetLabel = false; -#endif // !wxUSE_UNICODE } bool wxDataViewProgressRenderer::SetValue( const wxVariant &value ) { -#if !wxUSE_UNICODE - if ( m_needsToSetLabel ) - GTKSetLabel(); -#endif // !wxUSE_UNICODE - gint tmp = (long) value; wxGtkValue gvalue( G_TYPE_INT ); g_value_set_int( gvalue, tmp ); diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index b99921d43d..365c9f5898 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1250,30 +1250,7 @@ void wxTextCtrl::WriteText( const wxString &text ) return; } -#if wxUSE_UNICODE const wxScopedCharBuffer buffer(text.utf8_str()); -#else - // check if we have a specific style for the current position - wxFontEncoding enc = wxFONTENCODING_SYSTEM; - wxTextAttr style; - if ( GetStyle(GetInsertionPoint(), style) && style.HasFontEncoding() ) - { - enc = style.GetFontEncoding(); - } - - if ( enc == wxFONTENCODING_SYSTEM ) - enc = GetTextEncoding(); - - const wxScopedCharBuffer buffer(wxGTK_CONV_ENC(text, enc)); - if ( !buffer ) - { - // we must log an error here as losing the text like this can be a - // serious problem (e.g. imagine the document edited by user being - // empty instead of containing the correct text) - wxLogWarning(_("Failed to insert text in the control.")); - return; - } -#endif // First remove the selection if there is one gtk_text_buffer_delete_selection(m_buffer, false, true); diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index b48c5aba62..e65192eb24 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -116,52 +116,6 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) return wxGenericFindWindowAtPoint(pt); } -#if !wxUSE_UNICODE - -WXDLLIMPEXP_CORE wxCharBuffer -wxConvertToGTK(const wxString& s, wxFontEncoding enc) -{ - if (s.empty()) - return wxCharBuffer(""); - - wxWCharBuffer wbuf; - if ( enc == wxFONTENCODING_SYSTEM || enc == wxFONTENCODING_DEFAULT ) - { - wbuf = wxConvUI->cMB2WC(s.c_str()); - } - else // another encoding, use generic conversion class - { - wbuf = wxCSConv(enc).cMB2WC(s.c_str()); - } - - if (wbuf.length() == 0) - { - // conversion failed, but we still want to show something to the user - // even if it's going to be wrong it is better than nothing - // - // we choose ISO8859-1 here arbitrarily, it's just the most common - // encoding probably and, also importantly here, conversion from it - // never fails as it's done internally by wxCSConv - wbuf = wxCSConv(wxFONTENCODING_ISO8859_1).cMB2WC(s.c_str()); - } - - return wxConvUTF8.cWC2MB(wbuf); -} - -WXDLLIMPEXP_CORE wxCharBuffer -wxConvertFromGTK(const wxString& s, wxFontEncoding enc) -{ - // this conversion should never fail as GTK+ always uses UTF-8 internally - // so there are no complications here - const wxWCharBuffer wbuf(wxConvUTF8.cMB2WC(s.c_str())); - if ( enc == wxFONTENCODING_SYSTEM ) - return wxConvUI->cWC2MB(wbuf); - - return wxCSConv(enc).cWC2MB(wbuf); -} - -#endif // !wxUSE_UNICODE - // Returns nullptr if version is certainly greater or equal than major.minor.micro // Returns string describing the error if version is lower than // major.minor.micro OR it cannot be determined and one should not rely on the diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index cf588dc958..f6aaf4fb5a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1116,7 +1116,6 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, event.m_keyCode = key_code; -#if wxUSE_UNICODE event.m_uniChar = gdk_keyval_to_unicode(key_code ? key_code : gdk_event->keyval); if ( !event.m_uniChar && event.m_keyCode <= WXK_DELETE ) { @@ -1129,10 +1128,6 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, // sending a WXK_NONE key and let app deal with it the RawKeyCode if required if ( !key_code && !event.m_uniChar ) event.m_keyCode = WXK_NONE; -#else - if (!key_code) - event.m_keyCode = WXK_NONE; -#endif // wxUSE_UNICODE // now fill all the other fields wxFillOtherKeyEventFields(event, win, gdk_event); @@ -1180,20 +1175,16 @@ void AdjustCharEventKeyCodes(wxKeyEvent& event) else if ( code >= 'A' && code <= 'Z' ) event.m_keyCode = code - 'A' + 1; -#if wxUSE_UNICODE // Adjust the Unicode equivalent in the same way too. if ( event.m_keyCode != code ) event.m_uniChar = event.m_keyCode; -#endif // wxUSE_UNICODE } -#if wxUSE_UNICODE // Check for (b) from above. // // FIXME: Should we do it for key codes up to 255? if ( !event.m_uniChar && code < WXK_DELETE ) event.m_uniChar = code; -#endif // wxUSE_UNICODE } } // anonymous namespace @@ -1315,9 +1306,7 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), wxLogTrace(TRACE_KEYS, wxT("Char event: %ld"), key_code); eventChar.m_keyCode = key_code; -#if wxUSE_UNICODE eventChar.m_uniChar = gdk_keyval_to_unicode(key_code); -#endif // wxUSE_UNICODE AdjustCharEventKeyCodes(eventChar); @@ -1368,14 +1357,10 @@ bool wxWindowGTK::GTKDoInsertTextFromIM(const char* str) bool processed = false; for( wxString::const_iterator pstr = data.begin(); pstr != data.end(); ++pstr ) { -#if wxUSE_UNICODE event.m_uniChar = *pstr; // Backward compatible for ISO-8859-1 event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0; wxLogTrace(TRACE_KEYS, wxT("IM sent character '%c'"), event.m_uniChar); -#else - event.m_keyCode = (char)*pstr; -#endif // wxUSE_UNICODE AdjustCharEventKeyCodes(event); diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 8484625c51..7b791908cf 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -344,8 +344,7 @@ inline static wxString CacheReadString(wxInputStream *f) #define CURRENT_CACHED_BOOK_VERSION 5 // Additional flags to detect incompatibilities of the runtime environment: -#define CACHED_BOOK_FORMAT_FLAGS \ - (wxUSE_UNICODE << 0) +#define CACHED_BOOK_FORMAT_FLAGS 1 bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f) @@ -499,13 +498,8 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, const wxString& indexfile, const wxString& deftopic, const wxString& path) { -#if wxUSE_UNICODE #define CORRECT_STR(str, conv) \ str = wxString((str).mb_str(wxConvISO8859_1), conv) -#else - #define CORRECT_STR(str, conv) \ - str = wxString((str).wc_str(conv), wxConvLocal) -#endif wxFileSystem fsys; wxFSFile *fi; diff --git a/src/html/htmlfilt.cpp b/src/html/htmlfilt.cpp index da7bc0bea5..d8b890bbef 100644 --- a/src/html/htmlfilt.cpp +++ b/src/html/htmlfilt.cpp @@ -139,7 +139,6 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const // either Content-Type header or tags. In ANSI mode, we don't // do it as it is done by wxHtmlParser (for this reason, we add // tag if we used Content-Type header). -#if wxUSE_UNICODE int charsetPos; if ((charsetPos = file.GetMimeType().Find(wxT("; charset="))) != wxNOT_FOUND) { @@ -163,17 +162,6 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const doc = wxString( buf, conv ); } } -#else // !wxUSE_UNICODE - ReadString(doc, s, wxConvLibc); - // add meta tag if we obtained this through http: - if (!file.GetMimeType().empty()) - { - wxString hdr; - wxString mime = file.GetMimeType(); - hdr.Printf(wxT(""), mime); - return hdr+doc; - } -#endif return doc; } diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 734b535253..9312591b13 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -431,35 +431,13 @@ void wxHtmlTagHandler::ParseInnerSource(const wxString& source) wxIMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser, wxObject); wxHtmlEntitiesParser::wxHtmlEntitiesParser() -#if !wxUSE_UNICODE - : m_conv(nullptr), m_encoding(wxFONTENCODING_SYSTEM) -#endif { } wxHtmlEntitiesParser::~wxHtmlEntitiesParser() { -#if !wxUSE_UNICODE - delete m_conv; -#endif } -#if !wxUSE_UNICODE -void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) -{ - if (encoding == m_encoding) - return; - - delete m_conv; - - m_encoding = encoding; - if (m_encoding == wxFONTENCODING_SYSTEM) - m_conv = nullptr; - else - m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding)); -} -#endif // !wxUSE_UNICODE - wxString wxHtmlEntitiesParser::Parse(const wxString& input) const { wxString output; @@ -516,20 +494,6 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input) const return output; } -#if !wxUSE_UNICODE -wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const -{ - char buf[2]; - wchar_t wbuf[2]; - wbuf[0] = (wchar_t)code; - wbuf[1] = 0; - wxMBConv *conv = m_conv ? m_conv : &wxConvLocal; - if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) - return '?'; - return buf[0]; -} -#endif - struct wxHtmlEntityInfo { const wxStringCharType *name; diff --git a/src/html/m_layout.cpp b/src/html/m_layout.cpp index fc00350d7d..f591f91c70 100644 --- a/src/html/m_layout.cpp +++ b/src/html/m_layout.cpp @@ -279,15 +279,6 @@ TAG_HANDLER_BEGIN(TITLE, "TITLE") if (winIface) { wxString title(tag.GetBeginIter(), tag.GetEndIter1()); -#if !wxUSE_UNICODE - const wxFontEncoding enc = m_WParser->GetInputEncoding(); - if ( enc != wxFONTENCODING_DEFAULT ) - { - // need to convert to the current one - title = wxString(title.wc_str(wxCSConv(enc)), wxConvLocal); - } -#endif // !wxUSE_UNICODE - title = m_WParser->GetEntitiesParser()->Parse(title); winIface->SetHTMLWindowTitle(title); diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 37276d2fce..f484c766f7 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -43,12 +43,6 @@ wxHtmlWinParser::wxHtmlWinParser(wxHtmlWindowInterface *wndIface) m_DC = nullptr; m_CharHeight = m_CharWidth = 0; m_UseLink = false; -#if !wxUSE_UNICODE - m_nbsp = 0; - m_EncConv = nullptr; - m_InputEnc = wxFONTENCODING_ISO8859_1; - m_OutputEnc = wxFONTENCODING_DEFAULT; -#endif m_whitespaceMode = Whitespace_Normal; m_lastWordCell = nullptr; m_posColumn = 0; @@ -62,9 +56,6 @@ wxHtmlWinParser::wxHtmlWinParser(wxHtmlWindowInterface *wndIface) for (m = 0; m < 7; m++) { m_FontsTable[i][j][k][l][m] = nullptr; -#if !wxUSE_UNICODE - m_FontsEncTable[i][j][k][l][m] = wxFONTENCODING_DEFAULT; -#endif } SetFonts(wxEmptyString, wxEmptyString, nullptr); @@ -93,9 +84,6 @@ wxHtmlWinParser::~wxHtmlWinParser() if (m_FontsTable[i][j][k][l][m] != nullptr) delete m_FontsTable[i][j][k][l][m]; } -#if !wxUSE_UNICODE - delete m_EncConv; -#endif delete[] m_tmpStrBuf; } @@ -156,10 +144,6 @@ void wxHtmlWinParser::SetFonts(const wxString& normal_face, m_FontFaceFixed = fixed_face; m_FontFaceNormal = normal_face; -#if !wxUSE_UNICODE - SetInputEncoding(m_InputEnc); -#endif - for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) for (k = 0; k < 2; k++) @@ -228,16 +212,6 @@ void wxHtmlWinParser::InitParser(const wxString& source) // then open the first container into which page's content will go: OpenContainer(); -#if !wxUSE_UNICODE - wxString charset = ExtractCharsetInformation(source); - if (!charset.empty()) - { - wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset); - if (enc != wxFONTENCODING_SYSTEM) - SetInputEncoding(enc); - } -#endif - m_Container->InsertCell(new wxHtmlColourCell(m_ActualColor)); m_Container->InsertCell @@ -255,9 +229,6 @@ void wxHtmlWinParser::InitParser(const wxString& source) void wxHtmlWinParser::DoneParser() { m_Container = nullptr; -#if !wxUSE_UNICODE - SetInputEncoding(wxFONTENCODING_ISO8859_1); // for next call -#endif wxHtmlParser::DoneParser(); } @@ -334,21 +305,11 @@ wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, return GetFS()->OpenFile(myurl, flags); } -#if !wxUSE_UNICODE - #define NBSP_UNICODE_VALUE (160U) - #define CUR_NBSP_VALUE m_nbsp -#else - #define NBSP_UNICODE_VALUE (wxChar(160)) - #define CUR_NBSP_VALUE NBSP_UNICODE_VALUE -#endif +#define NBSP_UNICODE_VALUE (wxChar(160)) +#define CUR_NBSP_VALUE NBSP_UNICODE_VALUE void wxHtmlWinParser::AddText(const wxString& txt) { -#if !wxUSE_UNICODE - if ( m_nbsp == 0 ) - m_nbsp = GetEntitiesParser()->GetCharForCode(NBSP_UNICODE_VALUE); -#endif - if ( m_whitespaceMode == Whitespace_Normal ) { int templen = 0; @@ -439,11 +400,6 @@ void wxHtmlWinParser::FlushWordBuf(wxChar *buf, int& len) buf[i] = ' '; } -#if !wxUSE_UNICODE - if (m_EncConv) - m_EncConv->Convert(buf); -#endif - AddWord(wxString(buf, len)); len = 0; @@ -590,15 +546,8 @@ wxFont* wxHtmlWinParser::CreateCurrentFont() wxString face = ff ? m_FontFaceFixed : m_FontFaceNormal; wxString *faceptr = &(m_FontsFacesTable[fb][fi][fu][ff][fs]); wxFont **fontptr = &(m_FontsTable[fb][fi][fu][ff][fs]); -#if !wxUSE_UNICODE - wxFontEncoding *encptr = &(m_FontsEncTable[fb][fi][fu][ff][fs]); -#endif - if (*fontptr != nullptr && (*faceptr != face -#if !wxUSE_UNICODE - || *encptr != m_OutputEnc -#endif - )) + if (*fontptr != nullptr && (*faceptr != face)) { wxDELETE(*fontptr); } @@ -612,12 +561,7 @@ wxFont* wxHtmlWinParser::CreateCurrentFont() fi ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL, fb ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, fu ? true : false, face -#if wxUSE_UNICODE ); -#else - , m_OutputEnc); - *encptr = m_OutputEnc; -#endif } m_DC->SetFont(**fontptr); return (*fontptr); @@ -637,11 +581,6 @@ void wxHtmlWinParser::SetFontFace(const wxString& face) m_FontFaceFixed = face; else m_FontFaceNormal = face; - -#if !wxUSE_UNICODE - if (m_InputEnc != wxFONTENCODING_DEFAULT) - SetInputEncoding(m_InputEnc); -#endif } void wxHtmlWinParser::ApplyStateToCell(wxHtmlCell *cell) @@ -655,86 +594,6 @@ void wxHtmlWinParser::ApplyStateToCell(wxHtmlCell *cell) } -#if !wxUSE_UNICODE -void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc) -{ - // the character used for non-breakable space may change: - m_nbsp = 0; - - m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT; - wxDELETE(m_EncConv); - - if (enc == wxFONTENCODING_DEFAULT) - return; - - wxFontEncoding altfix, altnorm; - bool availfix, availnorm; - - availnorm = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceNormal); - availfix = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceFixed); - - if (availnorm && availfix) - { - // exact match? - m_OutputEnc = enc; - } - - else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false) && - wxFontMapper::Get()->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, false) && - altnorm == altfix) - { - // alternatives? - m_OutputEnc = altnorm; - } - else if (availnorm) - { - // at least normal face? - m_OutputEnc = enc; - } - else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false)) - { - m_OutputEnc = altnorm; - } - else - { -#ifndef __WXMAC__ - // okay, let's convert to ISO_8859-1, available always - m_OutputEnc = wxFONTENCODING_DEFAULT; -#else - m_OutputEnc = wxLocale::GetSystemEncoding() ; -#endif - } - - m_InputEnc = enc; - if (m_OutputEnc == wxFONTENCODING_DEFAULT) - { - GetEntitiesParser()->SetEncoding(wxFONTENCODING_SYSTEM); - } - else - { - GetEntitiesParser()->SetEncoding(m_OutputEnc); - } - - if (m_InputEnc == m_OutputEnc) - return; - - m_EncConv = new wxEncodingConverter(); - if (!m_EncConv->Init(m_InputEnc, - (m_OutputEnc == wxFONTENCODING_DEFAULT) ? - wxFONTENCODING_ISO8859_1 : m_OutputEnc, - wxCONVERT_SUBSTITUTE)) - { // total failure :-( - wxLogError(_("Failed to display HTML document in %s encoding"), - wxFontMapper::GetEncodingName(enc).c_str()); - m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT; - wxDELETE(m_EncConv); - } -} -#endif - - - - //----------------------------------------------------------------------------- // wxHtmlWinTagHandler //----------------------------------------------------------------------------- diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 0a420925d9..08ab9b0fac 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -505,12 +505,6 @@ int wxConsoleStderr::GetCommandHistory(wxWxCharBuffer& buf) const int len2 = m_pfnGetConsoleCommandHistory(buf.data(), len, CMD_EXE); -#if !wxUSE_UNICODE - // there seems to be a bug in the GetConsoleCommandHistoryA(), it - // returns the length of Unicode string and not ANSI one - len2 /= 2; -#endif // !wxUSE_UNICODE - if ( len2 != len ) { wxFAIL_MSG( wxT("failed getting history?") ); diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 5ba4916075..ef7caafb16 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -139,21 +139,6 @@ MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) return wxBitmap(icon); } -#if !wxUSE_UNICODE - -// SHSTOCKICONINFO always uses WCHAR, even in ANSI build, so we need to convert -// it to TCHAR, which is just CHAR in this case, used by the other functions. -// Provide an overload doing it as this keeps the code in the main function -// clean and this entire block (inside !wxUSE_UNICODE check) can be just -// removed when support for ANSI build is finally dropped. -wxBitmap -MSWGetBitmapFromIconLocation(const WCHAR* path, int index, const wxSize& size) -{ - return MSWGetBitmapFromIconLocation(wxString(path).mb_str(), index, size); -} - -#endif // !wxUSE_UNICODE - wxBitmap MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) { diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 519e5b031f..dd43f54ab1 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -137,20 +137,6 @@ bool wxControl::MSWCreateControl(const wxChar *classname, return false; } -#if !wxUSE_UNICODE - // Text labels starting with the character 0xff (which is a valid character - // in many code pages) don't appear correctly as CreateWindowEx() has some - // special treatment for this case, apparently the strings starting with -1 - // are not really strings but something called "ordinals". There is no - // documentation about it but the fact is that the label gets mangled or - // not displayed at all if we don't do this, see #9572. - // - // Notice that 0xffff is not a valid Unicode character so the problem - // doesn't arise in Unicode build. - if ( !label.empty() && label[0] == -1 ) - ::SetWindowText(GetHwnd(), label.t_str()); -#endif // !wxUSE_UNICODE - // saving the label in m_labelOrig to return it verbatim // later in GetLabel() m_labelOrig = label; diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index 2942850681..26bdbe7821 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -43,11 +43,7 @@ // macros and constants // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE - #define DDE_CP CP_WINUNICODE -#else - #define DDE_CP CP_WINANSI -#endif +#define DDE_CP CP_WINUNICODE #define GetHConv() ((HCONV)m_hConv) @@ -549,9 +545,8 @@ wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat format) size_t realSize = 0; wxMBConv *conv = nullptr; - // Windows only supports either ANSI or UTF-16 format depending on the + // Windows only supports UTF-16 format depending on the // build, so we need to convert the data if it doesn't use it already -#if wxUSE_UNICODE if ( format == wxIPC_TEXT ) { conv = &wxConvLibc; @@ -587,44 +582,6 @@ wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat format) // not the length of the string. realSize *= sizeof(wchar_t); } -#else // !wxUSE_UNICODE - if ( format == wxIPC_UNICODETEXT ) - { - conv = &wxConvLibc; - } - else if ( format == wxIPC_UTF8TEXT ) - { - // we could implement this in theory but it's not obvious how to pass - // the format information and, basically, why bother -- just use - // Unicode build - wxFAIL_MSG( wxT("UTF-8 text not supported in ANSI build") ); - - return false; - } - else // don't convert wxIPC_TEXT - { - realData = (LPBYTE)data; - realSize = size; - } - - if ( conv ) - { - const wchar_t * const wtext = (const wchar_t *)data; - const size_t len = size/sizeof(wchar_t); - - realSize = conv->FromWChar(nullptr, 0, wtext, len); - if ( realSize == wxCONV_FAILED ) - return false; - - realData = (LPBYTE)buffer.GetWriteBuf(realSize); - if ( !realData ) - return false; - - realSize = conv->FromWChar((char*)realData, realSize, wtext, len); - if ( realSize == wxCONV_FAILED ) - return false; - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE DWORD result; bool ok = DdeClientTransaction(realData, @@ -896,14 +853,8 @@ _DDECallback(UINT wType, DdeFreeDataHandle(hData); - // XTYP_EXECUTE can be used for text only and the text is - // always in ANSI format for ANSI build and Unicode format - // in Unicode build - #if wxUSE_UNICODE - wFmt = wxIPC_UNICODETEXT; - #else - wFmt = wxIPC_TEXT; - #endif + // XTYP_EXECUTE can be used for text only + wFmt = wxIPC_UNICODETEXT; if ( connection->OnExecute(connection->m_topicName, data, diff --git a/src/msw/hyperlink.cpp b/src/msw/hyperlink.cpp index b6096c2b5a..03eed2b3af 100644 --- a/src/msw/hyperlink.cpp +++ b/src/msw/hyperlink.cpp @@ -15,7 +15,7 @@ #include "wx/wxprec.h" -#if wxUSE_HYPERLINKCTRL && wxUSE_UNICODE +#if wxUSE_HYPERLINKCTRL #include "wx/hyperlink.h" @@ -183,4 +183,4 @@ bool wxHyperlinkCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) return wxGenericHyperlinkCtrl::MSWOnNotify(idCtrl, lParam, result); } -#endif // wxUSE_HYPERLINKCTRL && wxUSE_UNICODE +#endif // wxUSE_HYPERLINKCTRL diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 1a59a89491..dd9d39909d 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -123,23 +123,8 @@ wxGetListCtrlItemRect(HWND hwnd, int item, int flags, RECT& rect) // We have to handle both fooW and fooA notifications in several cases // because of broken comctl32.dll and/or unicows.dll. This class is used to -// convert LV_ITEMA and LV_ITEMW to LV_ITEM (which is either LV_ITEMA or -// LV_ITEMW depending on wxUSE_UNICODE setting), so that it can be processed -// by wxConvertToMSWListItem(). -#if wxUSE_UNICODE - #define LV_ITEM_NATIVE LV_ITEMW - #define LV_ITEM_OTHER LV_ITEMA - - #define LV_CONV_TO_WX cMB2WX - #define LV_CONV_BUF wxMB2WXbuf -#else // ANSI - #define LV_ITEM_NATIVE LV_ITEMA - #define LV_ITEM_OTHER LV_ITEMW - - #define LV_CONV_TO_WX cWC2WX - #define LV_CONV_BUF wxWC2WXbuf -#endif // Unicode/ANSI - +// convert LV_ITEMA to LV_ITEMW, so that it can be processed by +// wxConvertToMSWListItem(). class wxLV_ITEM { public: @@ -147,7 +132,7 @@ public: wxLV_ITEM() { m_buf = nullptr; m_pItem = nullptr; } // init without conversion - void Init(LV_ITEM_NATIVE& item) + void Init(LV_ITEMW& item) { wxASSERT_MSG( !m_pItem, wxT("Init() called twice?") ); @@ -155,30 +140,30 @@ public: } // init with conversion - void Init(const LV_ITEM_OTHER& item) + void Init(const LV_ITEMA& item) { // avoid unnecessary dynamic memory allocation, jjust make m_pItem // point to our own m_item // memcpy() can't work if the struct sizes are different - wxCOMPILE_TIME_ASSERT( sizeof(LV_ITEM_OTHER) == sizeof(LV_ITEM_NATIVE), + wxCOMPILE_TIME_ASSERT( sizeof(LV_ITEMA) == sizeof(LV_ITEMW), CodeCantWorkIfDiffSizes); - memcpy(&m_item, &item, sizeof(LV_ITEM_NATIVE)); + memcpy(&m_item, &item, sizeof(LV_ITEMW)); // convert text from ANSI to Unicod if necessary if ( (item.mask & LVIF_TEXT) && item.pszText ) { - m_buf = new LV_CONV_BUF(wxConvLocal.LV_CONV_TO_WX(item.pszText)); + m_buf = new wxWCharBuffer(wxConvLocal.cMB2WC(item.pszText)); m_item.pszText = (wxChar *)m_buf->data(); } } // ctor without conversion - wxLV_ITEM(LV_ITEM_NATIVE& item) : m_buf(nullptr), m_pItem(&item) { } + wxLV_ITEM(LV_ITEMW& item) : m_buf(nullptr), m_pItem(&item) { } // ctor with conversion - wxLV_ITEM(LV_ITEM_OTHER& item) : m_buf(nullptr) + wxLV_ITEM(LV_ITEMA& item) : m_buf(nullptr) { Init(item); } @@ -186,13 +171,13 @@ public: ~wxLV_ITEM() { delete m_buf; } // conversion to the real LV_ITEM - operator LV_ITEM_NATIVE&() const { return *m_pItem; } + operator LV_ITEMW&() const { return *m_pItem; } private: - LV_CONV_BUF *m_buf; + wxWCharBuffer *m_buf; - LV_ITEM_NATIVE *m_pItem; - LV_ITEM_NATIVE m_item; + LV_ITEMW *m_pItem; + LV_ITEMW m_item; wxDECLARE_NO_COPY_CLASS(wxLV_ITEM); }; diff --git a/src/msw/main.cpp b/src/msw/main.cpp index 17feaa7eed..096b862e75 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -26,10 +26,6 @@ #include "wx/utils.h" #endif //WX_PRECOMP -// wxCmdLineParser is only used when we can't use ::CommandLineToArgvW(). -#if !wxUSE_UNICODE - #include "wx/cmdline.h" -#endif #include "wx/dynlib.h" #include "wx/msw/private.h" @@ -201,7 +197,6 @@ struct wxMSWCommandLineArguments // In Unicode build prefer to use the standard function for tokenizing the // command line, but we can't use it with narrow strings, so use our own // approximation instead then. -#if wxUSE_UNICODE void Init() { argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); @@ -212,44 +207,6 @@ struct wxMSWCommandLineArguments if ( argc ) ::LocalFree(argv); } -#else // !wxUSE_UNICODE - void Init() - { - // Get the command line. - const wxChar* const cmdLine = ::GetCommandLine(); - if ( !cmdLine ) - return; - - // And tokenize it. - const wxArrayString args = wxCmdLineParser::ConvertStringToArgs(cmdLine); - - argc = args.size(); - - // +1 here for the terminating null pointer - argv = new wxChar *[argc + 1]; - for ( int i = 0; i < argc; i++ ) - { - argv[i] = wxStrdup(args[i].t_str()); - } - - // argv[] must be null-terminated - argv[argc] = nullptr; - } - - ~wxMSWCommandLineArguments() - { - if ( !argc ) - return; - - for ( int i = 0; i < argc; i++ ) - { - free(argv[i]); - } - - wxDELETEA(argv); - argc = 0; - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE int argc; wxChar **argv; diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 760cd7e99f..029de658bf 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -174,11 +174,7 @@ bool wxNotebook::Create(wxWindow *parent, } #endif //wxUSE_UXTHEME -#if defined(__WINE__) && wxUSE_UNICODE - LPCTSTR className = L"SysTabControl32"; -#else LPCTSTR className = WC_TABCONTROL; -#endif #if USE_NOTEBOOK_ANTIFLICKER // SysTabCtl32 class has natively CS_HREDRAW and CS_VREDRAW enabled and it diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 8cfbfae1ef..5c32727826 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -1344,7 +1344,7 @@ bool wxFileDataObject::GetDataHere(void *pData) const // initialize DROPFILES struct pDrop->pFiles = sizeof(DROPFILES); pDrop->fNC = FALSE; // not non-client coords - pDrop->fWide = wxUSE_UNICODE; + pDrop->fWide = TRUE; const size_t sizeOfChar = pDrop->fWide ? sizeof(wchar_t) : 1; @@ -1375,7 +1375,7 @@ bool wxFileDataObject::GetDataHere(void *pData) const // ---------------------------------------------------------------------------- // Work around bug in Wine headers -#if defined(__WINE__) && defined(CFSTR_SHELLURL) && wxUSE_UNICODE +#if defined(__WINE__) && defined(CFSTR_SHELLURL) #undef CFSTR_SHELLURL #define CFSTR_SHELLURL wxT("CFSTR_SHELLURL") #endif @@ -1450,15 +1450,10 @@ wxString wxURLDataObject::GetURL() const // CFSTR_SHELLURL is always ANSI so we need to convert it from it in // Unicode build -#if wxUSE_UNICODE wxCharBuffer buf(len); if ( m_dataObjectLast->GetDataHere(buf.data()) ) url = buf; -#else // !wxUSE_UNICODE - // in ANSI build no conversion is necessary - m_dataObjectLast->GetDataHere(wxStringBuffer(url, len)); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE } else // must be wxTextDataObject { @@ -1475,21 +1470,13 @@ void wxURLDataObject::SetURL(const wxString& url) { const size_t len = strlen(urlMB); -#if !wxUSE_UNICODE - // wxTextDataObject takes the number of characters in the string, not - // the size of the buffer (which would be len+1) - SetData(wxDF_TEXT, len, urlMB); -#endif // !wxUSE_UNICODE - // however CFSTR_SHELLURLDataObject doesn't append NUL automatically // but we probably still want to have it on the clipboard (just to be // safe), so do append it SetData(wxDataFormat(CFSTR_SHELLURL), len + 1, urlMB); } -#if wxUSE_UNICODE SetData(wxDF_UNICODETEXT, url.length()*sizeof(wxChar), url.wc_str()); -#endif } #if wxUSE_OLE diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index 7942f689dd..275c4c1841 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -47,21 +47,7 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr) const int len = SysStringLen(bStr); -#if wxUSE_UNICODE - wxString str(bStr, len); -#else - wxString str; - if (len) - { - wxStringBufferLength buf(str, len); // asserts if len == 0 - buf.SetLength(WideCharToMultiByte(CP_ACP, 0 /* no flags */, - bStr, len /* not necessarily NUL-terminated */, - buf, len, - nullptr, nullptr /* no default char */)); - } -#endif - - return str; + return wxString(bStr, len); } // ---------------------------------------------------------------------------- diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index b289bbb611..8d7640a991 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -1257,12 +1257,8 @@ static inline bool WriteAsciiString(wxOutputStream& ostr, const char *p) static inline bool WriteAsciiString(wxOutputStream& ostr, const wxString& s) { -#if wxUSE_UNICODE wxCharBuffer name(s.mb_str()); ostr.Write(name, strlen(name)); -#else - ostr.Write(s.mb_str(), s.length()); -#endif return ostr.IsOk(); } diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index c8b98b7c01..f0b9f45cd5 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -138,13 +138,7 @@ wxString wxStandardPaths::DoGetDirectory(int csidl) wxStringBuffer(dir, MAX_PATH) ); - // somewhat incredibly, the error code in the Unicode version is - // different from the one in ASCII version for this function -#if wxUSE_UNICODE if ( hr == E_FAIL ) -#else - if ( hr == S_FALSE ) -#endif { // directory doesn't exist, maybe we can get its default value? hr = ::SHGetFolderPath diff --git a/src/msw/taskbarbutton.cpp b/src/msw/taskbarbutton.cpp index 4e62472175..54a160de68 100644 --- a/src/msw/taskbarbutton.cpp +++ b/src/msw/taskbarbutton.cpp @@ -145,17 +145,10 @@ DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDestListSeparator, DEFINE_PROPERTYKEY(PKEY_Link_Arguments, 0x436f2667, 0x14e2, 0x4feb, 0xb3, 0x0a, 0x14, 0x6c, 0x53, 0xb5, 0xb6, 0x74, 100); -#ifdef wxUSE_UNICODE #define IShellLink wxIShellLinkW DEFINE_GUID(wxIID_IShellLink, 0x000214F9, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); -#else -#define IShellLink wxIShellLinkA - -DEFINE_GUID(wxIID_IShellLink, - 0x000214EE, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); -#endif // wxUSE_UNICODE typedef enum _SIGDN { diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index b6ac602638..68147b8597 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -499,11 +499,7 @@ bool wxTextCtrl::MSWCreateText(const wxString& value, // notice that 1.0 has no Unicode support at all so in Unicode build we // must use another version -#if wxUSE_UNICODE m_verRichEdit = 2; -#else // !wxUSE_UNICODE - m_verRichEdit = m_windowStyle & wxTE_RICH2 ? 2 : 1; -#endif // wxUSE_UNICODE/!wxUSE_UNICODE #if wxUSE_INKEDIT // First test if we can load an ink edit control. Normally, all edit @@ -544,12 +540,7 @@ bool wxTextCtrl::MSWCreateText(const wxString& value, } else if ( wxRichEditModule::Load(wxRichEditModule::Version_2or3) ) { - windowClass = wxT("RichEdit20") -#if wxUSE_UNICODE - wxT("W"); -#else // ANSI - wxT("A"); -#endif // Unicode/ANSI + windowClass = wxT("RichEdit20W"); } else // failed to load msftedit.dll and riched20.dll { @@ -1017,74 +1008,27 @@ wxString wxTextCtrl::GetRange(long from, long to) const if ( to == -1 ) to = len; -#if !wxUSE_UNICODE - // we must use EM_STREAMOUT if we don't want to lose all characters - // not representable in the current character set (EM_GETTEXTRANGE - // simply replaces them with question marks...) - if ( GetRichVersion() > 1 ) + // alloc one extra WORD as needed by the control + wxStringBuffer tmp(str, ++len); + wxChar *p = tmp; + + TEXTRANGE textRange; + textRange.chrg.cpMin = from; + textRange.chrg.cpMax = to; + textRange.lpstrText = p; + + (void)::SendMessage(GetHwnd(), EM_GETTEXTRANGE, + 0, (LPARAM)&textRange); + + if ( m_verRichEdit > 1 ) { - // we must have some encoding, otherwise any 8bit chars in the - // control are simply *lost* (replaced by '?') - wxFontEncoding encoding = wxFONTENCODING_SYSTEM; - - wxFont font = m_defaultStyle.GetFont(); - if ( !font.IsOk() ) - font = GetFont(); - - if ( font.IsOk() ) + // RichEdit 2.0 uses just CR ('\r') for the + // newlines which is neither Unix nor Windows + // style - convert it to something reasonable + for ( ; *p; p++ ) { - encoding = font.GetEncoding(); - } - -#if wxUSE_INTL - if ( encoding == wxFONTENCODING_SYSTEM ) - { - encoding = wxLocale::GetSystemEncoding(); - } -#endif // wxUSE_INTL - - if ( encoding == wxFONTENCODING_SYSTEM ) - { - encoding = wxFONTENCODING_ISO8859_1; - } - - str = StreamOut(encoding); - - if ( !str.empty() ) - { - // we have to manually extract the required part, luckily - // this is easy in this case as EOL characters in str are - // just LFs because we remove CRs in wxRichEditStreamOut - str = str.Mid(from, to - from); - } - } - - // StreamOut() wasn't used or failed, try to do it in normal way - if ( str.empty() ) -#endif // !wxUSE_UNICODE - { - // alloc one extra WORD as needed by the control - wxStringBuffer tmp(str, ++len); - wxChar *p = tmp; - - TEXTRANGE textRange; - textRange.chrg.cpMin = from; - textRange.chrg.cpMax = to; - textRange.lpstrText = p; - - (void)::SendMessage(GetHwnd(), EM_GETTEXTRANGE, - 0, (LPARAM)&textRange); - - if ( m_verRichEdit > 1 ) - { - // RichEdit 2.0 uses just CR ('\r') for the - // newlines which is neither Unix nor Windows - // style - convert it to something reasonable - for ( ; *p; p++ ) - { - if ( *p == wxT('\r') ) - *p = wxT('\n'); - } + if ( *p == wxT('\r') ) + *p = wxT('\n'); } } @@ -1149,167 +1093,6 @@ void wxTextCtrl::DoSetValue(const wxString& value, int flags) } } -#if wxUSE_RICHEDIT && !wxUSE_UNICODE - -// TODO: using memcpy() would improve performance a lot for big amounts of text - -DWORD CALLBACK -wxRichEditStreamIn(DWORD_PTR dwCookie, BYTE *buf, LONG cb, LONG *pcb) -{ - *pcb = 0; - - const wchar_t ** const ppws = (const wchar_t **)dwCookie; - - wchar_t *wbuf = (wchar_t *)buf; - const wchar_t *wpc = *ppws; - while ( cb && *wpc ) - { - *wbuf++ = *wpc++; - - cb -= sizeof(wchar_t); - (*pcb) += sizeof(wchar_t); - } - - *ppws = wpc; - - return 0; -} - -// helper struct used to pass parameters from wxTextCtrl to wxRichEditStreamOut -struct wxStreamOutData -{ - wchar_t *wpc; - size_t len; -}; - -DWORD CALLBACK -wxRichEditStreamOut(DWORD_PTR dwCookie, BYTE *buf, LONG cb, LONG *pcb) -{ - *pcb = 0; - - wxStreamOutData *data = (wxStreamOutData *)dwCookie; - - const wchar_t *wbuf = (const wchar_t *)buf; - wchar_t *wpc = data->wpc; - while ( cb ) - { - wchar_t wch = *wbuf++; - - // turn "\r\n" into "\n" on the fly - if ( wch != L'\r' ) - *wpc++ = wch; - else - data->len--; - - cb -= sizeof(wchar_t); - (*pcb) += sizeof(wchar_t); - } - - data->wpc = wpc; - - return 0; -} - - -bool -wxTextCtrl::StreamIn(const wxString& value, - wxFontEncoding encoding, - bool selectionOnly) -{ - wxCSConv conv(encoding); - - const size_t len = conv.MB2WC(nullptr, value.mb_str(), value.length()); - - if (len == wxCONV_FAILED) - return false; - - wxWCharBuffer wchBuf(len); // allocates one extra character - wchar_t *wpc = wchBuf.data(); - - conv.MB2WC(wpc, value.mb_str(), len + 1); - - // finally, stream it in the control - EDITSTREAM eds; - wxZeroMemory(eds); - eds.dwCookie = (DWORD_PTR)&wpc; - // the cast below is needed for broken (very) old mingw32 headers - eds.pfnCallback = (EDITSTREAMCALLBACK)wxRichEditStreamIn; - - // same problem as in DoWriteText(): we can get multiple events here - UpdatesCountFilter ucf(m_updatesCount); - - ::SendMessage(GetHwnd(), EM_STREAMIN, - SF_TEXT | - SF_UNICODE | - (selectionOnly ? SFF_SELECTION : 0), - (LPARAM)&eds); - - // It's okay for EN_UPDATE to not be sent if the selection is empty and - // the text is empty, otherwise warn the programmer about it. - wxASSERT_MSG( ucf.GotUpdate() || ( !HasSelection() && value.empty() ), - wxT("EM_STREAMIN didn't send EN_UPDATE?") ); - - if ( eds.dwError ) - { - wxLogLastError(wxT("EM_STREAMIN")); - } - - return true; -} - -wxString -wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const -{ - wxString out; - - const int len = GetWindowTextLength(GetHwnd()); - - wxWCharBuffer wchBuf(len); - wchar_t *wpc = wchBuf.data(); - - wxStreamOutData data; - data.wpc = wpc; - data.len = len; - - EDITSTREAM eds; - wxZeroMemory(eds); - eds.dwCookie = (DWORD_PTR)&data; - eds.pfnCallback = wxRichEditStreamOut; - - ::SendMessage - ( - GetHwnd(), - EM_STREAMOUT, - SF_TEXT | SF_UNICODE | (selectionOnly ? SFF_SELECTION : 0), - (LPARAM)&eds - ); - - if ( eds.dwError ) - { - wxLogLastError(wxT("EM_STREAMOUT")); - } - else // streamed out ok - { - // NUL-terminate the string because its length could have been - // decreased by wxRichEditStreamOut - *(wchBuf.data() + data.len) = L'\0'; - - // now convert to the given encoding (this is a possibly lossful - // conversion but what else can we do) - wxCSConv conv(encoding); - size_t lenNeeded = conv.WC2MB(nullptr, wchBuf, 0); - - if ( lenNeeded != wxCONV_FAILED && lenNeeded++ ) - { - conv.WC2MB(wxStringBuffer(out, lenNeeded), wchBuf, lenNeeded); - } - } - - return out; -} - -#endif // wxUSE_RICHEDIT - void wxTextCtrl::WriteText(const wxString& value) { DoWriteText(value); @@ -1325,8 +1108,6 @@ void wxTextCtrl::DoWriteText(const wxString& value, int flags) valueDos = value; #if wxUSE_RICHEDIT - // there are several complications with the rich edit controls here - bool done = false; if ( IsRich() ) { // first, ensure that the new text will be in the default style @@ -1336,76 +1117,49 @@ void wxTextCtrl::DoWriteText(const wxString& value, int flags) GetSelection(&start, &end); SetStyle(start, end, m_defaultStyle); } - -#if !wxUSE_UNICODE - // next check if the text we're inserting must be shown in a non - // default charset -- this only works for RichEdit > 1.0 - if ( GetRichVersion() > 1 ) - { - wxFont font = m_defaultStyle.GetFont(); - if ( !font.IsOk() ) - font = GetFont(); - - if ( font.IsOk() ) - { - wxFontEncoding encoding = font.GetEncoding(); - if ( encoding != wxFONTENCODING_SYSTEM ) - { - // we have to use EM_STREAMIN to force richedit control 2.0+ - // to show any text in the non default charset -- otherwise - // it thinks it knows better than we do and always shows it - // in the default one - done = StreamIn(valueDos, encoding, selectionOnly); - } - } - } -#endif // !wxUSE_UNICODE } - if ( !done ) #endif // wxUSE_RICHEDIT + // in some cases we get 2 EN_CHANGE notifications after the SendMessage + // call (this happens for plain EDITs with EM_REPLACESEL and under some + // -- undetermined -- conditions with rich edit) and sometimes we don't + // get any events at all (plain EDIT with WM_SETTEXT), so ensure that + // we generate exactly one of them by ignoring all but the first one in + // SendUpdateEvent() and generating one ourselves if we hadn't got any + // notifications from Windows + if ( !(flags & SetValue_SendEvent) ) + m_updatesCount = -2; // suppress any update event + + UpdatesCountFilter ucf(m_updatesCount); + + // Remember the length of the text we're inserting so that + // AdjustSpaceLimit() could adjust the limit to be big enough for it: + // and also signal us whether it did it by resetting it to 0. + gs_lenOfInsertedText.push(valueDos.length()); + + ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, + // EM_REPLACESEL takes 1 to indicate the operation should be redoable + selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos)); + + const int lenActuallyInserted = gs_lenOfInsertedText.top(); + gs_lenOfInsertedText.pop(); + + if ( lenActuallyInserted == -1 ) { - // in some cases we get 2 EN_CHANGE notifications after the SendMessage - // call (this happens for plain EDITs with EM_REPLACESEL and under some - // -- undetermined -- conditions with rich edit) and sometimes we don't - // get any events at all (plain EDIT with WM_SETTEXT), so ensure that - // we generate exactly one of them by ignoring all but the first one in - // SendUpdateEvent() and generating one ourselves if we hadn't got any - // notifications from Windows - if ( !(flags & SetValue_SendEvent) ) - m_updatesCount = -2; // suppress any update event - - UpdatesCountFilter ucf(m_updatesCount); - - // Remember the length of the text we're inserting so that - // AdjustSpaceLimit() could adjust the limit to be big enough for it: - // and also signal us whether it did it by resetting it to 0. - gs_lenOfInsertedText.push(valueDos.length()); + // Text size limit has been hit and added text has been truncated. + // But the max length has been increased by the EN_MAXTEXT message + // handler, which also reset the top of the lengths stack to -1), + // so we should be able to set it successfully now if we try again. + if ( selectionOnly ) + Undo(); ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, - // EM_REPLACESEL takes 1 to indicate the operation should be redoable selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos)); + } - const int lenActuallyInserted = gs_lenOfInsertedText.top(); - gs_lenOfInsertedText.pop(); - - if ( lenActuallyInserted == -1 ) - { - // Text size limit has been hit and added text has been truncated. - // But the max length has been increased by the EN_MAXTEXT message - // handler, which also reset the top of the lengths stack to -1), - // so we should be able to set it successfully now if we try again. - if ( selectionOnly ) - Undo(); - - ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, - selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos)); - } - - if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) ) - { - SendUpdateEvent(); - } + if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) ) + { + SendUpdateEvent(); } } diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 0a8473ed26..bcb5fccc90 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -770,13 +770,11 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, // NUL-terminated strings. if ( !env->env.empty() ) { -#if wxUSE_UNICODE // Environment variables can contain non-ASCII characters. We could // check for it and not use this flag if everything is really ASCII // only but there doesn't seem to be any reason to do it so just // assume Unicode by default. dwFlags |= CREATE_UNICODE_ENVIRONMENT; -#endif // wxUSE_UNICODE wxEnvVariableHashMap::const_iterator it; @@ -1118,12 +1116,8 @@ long wxExecute(const char* const* argv, int flags, wxProcess* handler, return wxExecuteImpl(argv, flags, handler, env); } -#if wxUSE_UNICODE - long wxExecute(const wchar_t* const* argv, int flags, wxProcess* handler, const wxExecuteEnv *env) { return wxExecuteImpl(argv, flags, handler, env); } - -#endif // wxUSE_UNICODE diff --git a/src/msw/window.cpp b/src/msw/window.cpp index b51b1ae783..ec8de21712 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4194,47 +4194,9 @@ bool wxWindowMSW::HandleTooltipNotify(WXUINT code, // // Note that using a static buffer should not be a problem as only a single // tooltip can be shown at the same time anyhow. -#if !wxUSE_UNICODE - if ( code == (WXUINT) TTN_NEEDTEXTW ) - { - // We need to convert tooltip from multi byte to Unicode on the fly. - static wchar_t buf[513]; - - // Truncate tooltip length if needed as otherwise we might not have - // enough space for it in the buffer and MultiByteToWideChar() would - // return an error - size_t tipLength = wxMin(ttip.length(), WXSIZEOF(buf) - 1); - - // Convert to WideChar without adding the NUL character. The NUL - // character is added afterwards (this is more efficient). - int len = ::MultiByteToWideChar - ( - CP_ACP, - 0, // no flags - ttip.t_str(), - tipLength, - buf, - WXSIZEOF(buf) - 1 - ); - - if ( !len ) - { - wxLogLastError(wxT("MultiByteToWideChar()")); - } - - buf[len] = L'\0'; - ttText->lpszText = (LPSTR) buf; - } - else // TTN_NEEDTEXTA -#endif // !wxUSE_UNICODE - { - // we get here if we got TTN_NEEDTEXTA (only happens in ANSI build) or - // if we got TTN_NEEDTEXTW in Unicode build: in this case we just have - // to copy the string we have into the buffer - static wxChar buf[513]; - wxStrlcpy(buf, ttip.c_str(), WXSIZEOF(buf)); - ttText->lpszText = buf; - } + static wxChar buf[513]; + wxStrlcpy(buf, ttip.c_str(), WXSIZEOF(buf)); + ttText->lpszText = buf; return true; } @@ -4882,7 +4844,7 @@ bool wxSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWi // uiAction values corresponding to strings and use a temporary wide buffer // for them, and convert the returned value to ANSI after the call. Instead // of doing all this, just don't use it at all in the deprecated ANSI build. -#if wxUSE_DYNLIB_CLASS && wxUSE_UNICODE +#if wxUSE_DYNLIB_CLASS if ( !window ) window = wxApp::GetMainTopWindow(); @@ -6406,9 +6368,7 @@ wxWindowMSW::CreateKeyEvent(wxEventType evType, ( wParam, lParam -#if wxUSE_UNICODE , &event.m_uniChar -#endif // wxUSE_UNICODE ); return event; @@ -6422,11 +6382,9 @@ wxWindowMSW::CreateCharEvent(wxEventType evType, wxKeyEvent event(evType); InitAnyKeyEvent(event, wParam, lParam); -#if wxUSE_UNICODE // TODO: wParam uses UTF-16 so this is incorrect for characters outside of // the BMP, we should use WM_UNICHAR to handle them. event.m_uniChar = wParam; -#endif // wxUSE_UNICODE // Set non-Unicode key code too for compatibility if possible. if ( wParam < 0x80 ) @@ -7233,9 +7191,7 @@ wxKeyboardHook(int nCode, WXWPARAM wParam, WXLPARAM lParam) if ( !gs_modalEntryWindowCount && !::GetCapture() ) { if ( id != WXK_NONE -#if wxUSE_UNICODE || static_cast(uc) != WXK_NONE -#endif // wxUSE_UNICODE ) { wxWindow const* win = wxWindow::DoFindFocus(); @@ -7251,9 +7207,7 @@ wxKeyboardHook(int nCode, WXWPARAM wParam, WXLPARAM lParam) MSWInitAnyKeyEvent(event, wParam, lParam, win); event.m_keyCode = id; -#if wxUSE_UNICODE event.m_uniChar = uc; -#endif // wxUSE_UNICODE wxEvtHandler * const handler = win ? win->GetEventHandler() : wxTheApp; diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index 48405ba557..e5747b6cf7 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -241,17 +241,10 @@ wxMacAssertOutputHandler(const char *WXUNUSED(componentName), wxString exceptionStr ; wxString errorStr ; -#if wxUSE_UNICODE fileNameStr = wxString(fileName, wxConvLocal); assertionStr = wxString(assertionString, wxConvLocal); exceptionStr = wxString((exceptionLabelString!=nullptr) ? exceptionLabelString : "", wxConvLocal) ; errorStr = wxString((errorString!=nullptr) ? errorString : "", wxConvLocal) ; -#else - fileNameStr = fileName; - assertionStr = assertionString; - exceptionStr = (exceptionLabelString!=0) ? exceptionLabelString : "" ; - errorStr = (errorString!=0) ? errorString : "" ; -#endif // turn this on, if you want the macOS asserts to flow into log, otherwise they are handled via wxOnAssert #if 0 @@ -886,9 +879,7 @@ void wxApp::MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymess event.m_altDown = modifiers & optionKey; event.m_controlDown = modifiers & cmdKey; event.m_keyCode = keyval ; -#if wxUSE_UNICODE event.m_uniChar = uniChar ; -#endif event.m_rawCode = keymessage; event.m_rawFlags = modifiers; diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 888ba785d4..8d0998f8fc 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -350,11 +350,7 @@ void wxDataObject::WriteToSink(wxOSXDataSink * datatransfer) const { wxString filenames; -#if wxUSE_UNICODE filenames = wxString( (const char*)buf, *wxConvFileName ); -#else - filenames = wxString (wxConvLocal.cWC2WX(wxConvFileName->cMB2WC( (const char*)buf))); -#endif wxArrayString files = wxStringTokenize( filenames, wxT("\n"), wxTOKEN_STRTOK ); for ( size_t j = 0 ; j < files.GetCount(); ++j ) @@ -586,14 +582,12 @@ void wxDataObject::AddSupportedTypes( CFMutableArrayRef cfarray, Direction dir) // wxTextDataObject // ---------------------------------------------------------------------------- -#if wxUSE_UNICODE void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir)) const { *formats++ = wxDataFormat(wxDF_UNICODETEXT); *formats = wxDataFormat(wxDF_TEXT); } -#endif // ---------------------------------------------------------------------------- // wxFileDataObject @@ -642,11 +636,7 @@ bool wxFileDataObject::SetData( size_t WXUNUSED(nSize), const void *pBuf ) { wxString filenames; -#if wxUSE_UNICODE filenames = wxString( (const char*)pBuf, *wxConvFileName ); -#else - filenames = wxString (wxConvLocal.cWC2WX(wxConvFileName->cMB2WC( (const char*)pBuf))); -#endif m_filenames = wxStringTokenize( filenames, wxT("\n"), wxTOKEN_STRTOK ); diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index b28b49af08..4b9d44b281 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -621,20 +621,12 @@ void wxMacCocoaShowCursor() wxString wxStringWithNSString(NSString *nsstring) { -#if wxUSE_UNICODE return wxString([nsstring UTF8String], wxConvUTF8); -#else - return wxString([nsstring lossyCString]); -#endif // wxUSE_UNICODE } NSString* wxNSStringWithWxString(const wxString &wxstring) { -#if wxUSE_UNICODE return [NSString stringWithUTF8String: wxstring.mb_str(wxConvUTF8)]; -#else - return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()]; -#endif // wxUSE_UNICODE } // ---------------------------------------------------------------------------- diff --git a/src/osx/cocoa/msgdlg.mm b/src/osx/cocoa/msgdlg.mm index 33fe1143b7..6e56893b3d 100644 --- a/src/osx/cocoa/msgdlg.mm +++ b/src/osx/cocoa/msgdlg.mm @@ -91,11 +91,7 @@ int wxMessageDialog::ShowModal() CFStringRef alternateButtonTitle = nullptr; CFStringRef otherButtonTitle = nullptr; -#if wxUSE_UNICODE wxFontEncoding encoding = wxFONTENCODING_DEFAULT; -#else - wxFontEncoding encoding = GetFont().GetEncoding(); -#endif wxCFStringRef cfTitle( msgtitle, encoding ); wxCFStringRef cfText( msgtext, encoding ); @@ -242,11 +238,7 @@ void* wxMessageDialog::ConstructNSAlert() NSAlert* alert = [[NSAlert alloc] init]; NSAlertStyle alertType = GetAlertStyleFromWXStyle(style); -#if wxUSE_UNICODE wxFontEncoding encoding = wxFONTENCODING_DEFAULT; -#else - wxFontEncoding encoding = GetFont().GetEncoding(); -#endif wxCFStringRef cfNoString( wxControl::GetLabelText(GetNoLabel()), encoding ); wxCFStringRef cfYesString( wxControl::GetLabelText(GetYesLabel()), encoding ); diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index e872e7bfc2..7a754b50b2 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -523,7 +523,6 @@ void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, N keyval = aunichar; } -#if wxUSE_UNICODE // OS X generates events with key codes in Unicode private use area for // unprintable symbols such as cursor arrows (WXK_UP is mapped to U+F700) // and function keys (WXK_F2 is U+F705). We don't want to use them as the @@ -534,7 +533,7 @@ void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, N // as key codes beyond it don't seem to be currently used. if ( !(aunichar >= 0xe000 && aunichar < 0xf900) ) wxevent.m_uniChar = aunichar; -#endif + wxevent.m_keyCode = keyval; wxWindowMac* peer = GetWXPeer(); @@ -3780,9 +3779,7 @@ bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text) wxevent.m_rawFlags = 0; const wxChar aunichar = *it; -#if wxUSE_UNICODE wxevent.m_uniChar = aunichar; -#endif wxevent.m_keyCode = aunichar < 0x80 ? aunichar : WXK_NONE; wxevent.SetEventObject(peer); diff --git a/src/osx/core/cfstring.cpp b/src/osx/core/cfstring.cpp index dfb9badf47..3c4cf5bebb 100644 --- a/src/osx/core/cfstring.cpp +++ b/src/osx/core/cfstring.cpp @@ -587,7 +587,7 @@ wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) // converts this string into a core foundation string with optional pc 2 mac encoding -wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UNICODE(encoding) ) +wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED(encoding) ) { if (st.IsEmpty()) { @@ -596,7 +596,6 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN else { wxString str(wxMacConvertNewlines13To10(st)); -#if wxUSE_UNICODE #if wxUSE_UNICODE_WCHAR // native = wchar_t 4 bytes for us const wchar_t * const data = str.wc_str(); @@ -620,10 +619,6 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN { reset( wxCFRetain( CFSTR("") ) ); } -#else // not wxUSE_UNICODE - reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - wxMacGetSystemEncFromFontEnc( encoding ) ) ); -#endif } } @@ -639,7 +634,7 @@ wxString wxCFStringRef::AsStringWithNormalizationFormC( CFStringRef ref, wxFontE return str; } -wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UNICODE(encoding) ) +wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED(encoding) ) { if ( !ref ) return wxEmptyString ; @@ -648,7 +643,6 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN CFStringEncoding cfencoding; wxString result; -#if wxUSE_UNICODE #if wxUSE_UNICODE_WCHAR cfencoding = kCFStringEncodingUTF32Native; #elif wxUSE_UNICODE_UTF8 @@ -656,9 +650,6 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN #else #error "unsupported unicode representation" #endif -#else - cfencoding = wxMacGetSystemEncFromFontEnc( encoding ); -#endif CFIndex cStrLen ; CFStringGetBytes( ref , CFRangeMake(0, cflen) , cfencoding , @@ -667,7 +658,6 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN CFStringGetBytes( ref , CFRangeMake(0, cflen) , cfencoding, '?' , false , (unsigned char*) buf , cStrLen , &cStrLen) ; -#if wxUSE_UNICODE #if wxUSE_UNICODE_WCHAR result = wxString( (const wchar_t*) buf , cStrLen/4); #elif wxUSE_UNICODE_UTF8 @@ -675,9 +665,6 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN #else #error "unsupported unicode representation" #endif -#else - result = wxString(buf, cStrLen) ; -#endif delete[] buf ; return wxMacConvertNewlines10To13(result); diff --git a/src/osx/core/strconv_cf.cpp b/src/osx/core/strconv_cf.cpp index 79dc5fe849..830a53b5e7 100644 --- a/src/osx/core/strconv_cf.cpp +++ b/src/osx/core/strconv_cf.cpp @@ -188,16 +188,9 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding) wxMacUniCharBuffer::wxMacUniCharBuffer( const wxString &str ) { wxMBConvUTF16 converter ; -#if wxUSE_UNICODE size_t unicharlen = converter.WC2MB( nullptr , str.wc_str() , 0 ) ; m_ubuf = (UniChar*) malloc( unicharlen + 2 ) ; converter.WC2MB( (char*) m_ubuf , str.wc_str(), unicharlen + 2 ) ; -#else - const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ; - size_t unicharlen = converter.WC2MB( nullptr , wchar.data() , 0 ) ; - m_ubuf = (UniChar*) malloc( unicharlen + 2 ) ; - converter.WC2MB( (char*) m_ubuf , wchar.data() , unicharlen + 2 ) ; -#endif m_chars = unicharlen / 2 ; } diff --git a/src/qt/app.cpp b/src/qt/app.cpp index fdb8463d3e..57552ca807 100644 --- a/src/qt/app.cpp +++ b/src/qt/app.cpp @@ -72,11 +72,7 @@ bool wxApp::Initialize( int &argc, wxChar **argv ) argv = new wxChar *[qtArgs.size() + 1]; for ( int i = 0; i < qtArgs.size(); i++ ) { -#if wxUSE_UNICODE argv[i] = wxStrdupW( wxConvUTF8.cMB2WX( qtArgs[i].toUtf8().data() ) ); -#else // wxUSE_UNICODE - argv[i] = wxStrdupA( wxConvUTF8.cMB2WX( qtArgs[i].toUtf8().data() ) ); -#endif // wxUSE_UNICODE } argc = m_qtApplication->arguments().size(); diff --git a/src/qt/dataobj.cpp b/src/qt/dataobj.cpp index 83e4f659f2..a2fc9460e0 100644 --- a/src/qt/dataobj.cpp +++ b/src/qt/dataobj.cpp @@ -235,14 +235,12 @@ bool wxBitmapDataObject::QtSetDataFrom(const QMimeData &mimeData) // wxTextDataObject // --------------------------------------------------------------------------- -#if wxUSE_UNICODE void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir)) const { formats[0] = wxDataFormat(wxDF_UNICODETEXT); formats[1] = wxDataFormat(wxDF_TEXT); } -#endif void wxTextDataObject::QtSetDataSingleFormat(const QMimeData &mimeData, const wxDataFormat &WXUNUSED(format)) { diff --git a/src/qt/window.cpp b/src/qt/window.cpp index f2b571e9d1..0a4fa90578 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -1411,12 +1411,10 @@ bool wxWindowQt::QtHandleKeyEvent ( QWidget *WXUNUSED( handler ), QKeyEvent *eve // TODO: m_x, m_y e.m_keyCode = wxQtConvertKeyCode( event->key(), event->modifiers() ); -#if wxUSE_UNICODE if ( event->text().isEmpty() ) e.m_uniChar = 0; else e.m_uniChar = event->text().at( 0 ).unicode(); -#endif // wxUSE_UNICODE e.m_rawCode = event->nativeVirtualKey(); e.m_rawFlags = event->nativeModifiers(); diff --git a/src/regex/regc_locale.c b/src/regex/regc_locale.c index d688563a67..b583bb43e2 100644 --- a/src/regex/regc_locale.c +++ b/src/regex/regc_locale.c @@ -123,8 +123,6 @@ static struct cname { {NULL, 0} }; -#if wxUSE_UNICODE - /* Unicode character-class tables */ typedef struct crange { @@ -590,57 +588,6 @@ Tcl_UniChar Tcl_UniCharToTitle(int ch) } } -#else /* wxUSE_UNICODE */ - -#include - -typedef int (*isfunc_t)(int); - -/* ASCII character-class table */ -static struct cclass { - char *name; - char *chars; - int hasch; - isfunc_t isfunc; -} cclasses[] = { - {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789", 1, isalnum}, - {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - 1, isalpha}, - {"blank", " \t", 0, NULL}, - {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ -\25\26\27\30\31\32\33\34\35\36\37\177", 0, iscntrl}, - {"digit", "0123456789", 0, isdigit}, - {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - 1, isgraph}, - {"lower", "abcdefghijklmnopqrstuvwxyz", - 1, islower}, - {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", - 1, isprint}, - {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - 0, ispunct}, - {"space", "\t\n\v\f\r ", 0, isspace}, - {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - 0, isupper}, - {"xdigit", "0123456789ABCDEFabcdef", - 0, isxdigit}, - {NULL, 0, 0, NULL} -}; - -/* - * Supply implementations for some tcl functions that this module depends on - * to make it self contained - */ - -#define Tcl_UniChar wxChar -Tcl_UniChar Tcl_UniCharToUpper(int ch) { return wxCRT_ToupperNative(ch); } -Tcl_UniChar Tcl_UniCharToLower(int ch) { return wxCRT_TolowerNative(ch); } -Tcl_UniChar Tcl_UniCharToTitle(int ch) { return wxCRT_ToupperNative(ch); } - -#endif /* !wxUSE_UNICODE */ - #define CH NOCELT /* @@ -826,8 +773,6 @@ eclass(v, c, cases) return cv; } -#if wxUSE_UNICODE - /* - cclass - supply cvec for a character class * Must include case counterparts on request. @@ -1036,79 +981,6 @@ cclass(v, startp, endp, cases) return cv; } -#else /* wxUSE_UNICODE */ - -static struct cvec * -cclass(v, startp, endp, cases) -struct vars *v; -chr *startp; /* where the name starts */ -chr *endp; /* just past the end of the name */ -int cases; /* case-independent? */ -{ - size_t len; - char *p; - struct cclass *cc; - struct cvec *cv; - chr *np; - int i; - int count; - char buf[256]; - const char *loc; - - /* find the name */ - len = endp - startp; - np = startp; - if (cases && len == 5 && (wxCRT_StrncmpNative(wxT("lower"), np, 5) == 0 || - wxCRT_StrncmpNative(wxT("upper"), np, 5) == 0)) - np = wxT("alpha"); - for (cc = cclasses; cc->name != NULL; cc++) - if (wxCRT_StrlenNative(cc->name) == len && wxCRT_StrncmpNative(cc->name, np, len) == 0) - break; /* NOTE BREAK OUT */ - if (cc->name == NULL) { - ERR(REG_ECTYPE); - return NULL; - } - - loc = setlocale(LC_CTYPE, NULL); - - if (!cc->isfunc || loc == NULL || strcmp(loc, "C") == 0) - { - /* set up vector */ - cv = getcvec(v, (int)strlen(cc->chars), 0, 0); - if (cv == NULL) { - ERR(REG_ESPACE); - return NULL; - } - - /* fill it in */ - for (p = cc->chars; *p != '\0'; p++) - addchr(cv, (chr)*p); - } - else - { - count = 0; - for (i = 0; i < 256; i++) - if (cc->isfunc(i)) - buf[count++] = i; - - /* set up vector */ - cv = getcvec(v, count, 0, 0); - if (cv == NULL) { - ERR(REG_ESPACE); - return NULL; - } - - /* fill it in */ - for (i = 0; i < count; i++) - addchr(cv, buf[i]); - } - - return cv; -} - -#endif /* !wxUSE_UNICODE */ - - /* - allcases - supply cvec for all case counterparts of a chr (including itself) * This is a shortcut, preferably an efficient one, for simple characters; diff --git a/src/regex/regcustom.h b/src/regex/regcustom.h index 69e7c92069..d7fa0ab5e2 100644 --- a/src/regex/regcustom.h +++ b/src/regex/regcustom.h @@ -70,12 +70,10 @@ #ifdef __REG_NOCHAR #undef __REG_NOCHAR #endif -#if wxUSE_UNICODE -# define __REG_WIDE_T wxChar -# define __REG_WIDE_COMPILE wx_re_comp -# define __REG_WIDE_EXEC wx_re_exec -# define __REG_NOCHAR /* don't want the char versions */ -#endif +#define __REG_WIDE_T wxChar +#define __REG_WIDE_COMPILE wx_re_comp +#define __REG_WIDE_EXEC wx_re_exec +#define __REG_NOCHAR /* don't want the char versions */ #define __REG_NOFRONT /* don't want regcomp() and regexec() */ #define _ANSI_ARGS_(x) x /* --- end --- */ @@ -89,11 +87,7 @@ typedef int celt; /* type to hold chr, MCCE number, or NOCELT */ #define UCHAR(c) ((unsigned char) (c)) #define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */ #define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ -#if !wxUSE_UNICODE -# define CHRBITS 8 /* bits in a chr; must not use sizeof */ -# define CHR_MIN 0x00 /* smallest and largest chr; the value */ -# define CHR_MAX 0xff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ -#elif SIZEOF_WCHAR_T == 4 +#if SIZEOF_WCHAR_T == 4 # define CHRBITS 32 /* bits in a chr; must not use sizeof */ # define CHR_MIN 0x00000000 /* smallest and largest chr; the value */ # define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ diff --git a/src/regex/regex.h b/src/regex/regex.h index 0120ac3018..ecf61e4741 100644 --- a/src/regex/regex.h +++ b/src/regex/regex.h @@ -107,12 +107,10 @@ extern "C" { #ifdef __REG_NOCHAR #undef __REG_NOCHAR #endif -#if wxUSE_UNICODE -# define __REG_WIDE_T wxChar -# define __REG_WIDE_COMPILE wx_re_comp -# define __REG_WIDE_EXEC wx_re_exec -# define __REG_NOCHAR /* don't want the char versions */ -#endif +#define __REG_WIDE_T wxChar +#define __REG_WIDE_COMPILE wx_re_comp +#define __REG_WIDE_EXEC wx_re_exec +#define __REG_NOCHAR /* don't want the char versions */ #define __REG_NOFRONT /* don't want regcomp() and regexec() */ #define _ANSI_ARGS_(x) x /* --- end --- */ diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 1d9fe2198e..0dbbef0875 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -8945,9 +8945,7 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) } } else if (wxTheClipboard->IsSupported(wxDF_TEXT) - #if wxUSE_UNICODE || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) - #endif ) { wxTextDataObject data; @@ -9013,9 +9011,7 @@ bool wxRichTextBuffer::CanPasteFromClipboard() const if (!wxTheClipboard->IsOpened() && wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_TEXT) -#if wxUSE_UNICODE || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) -#endif || wxTheClipboard->IsSupported(wxDataFormat(wxRichTextBufferDataObject::GetRichTextBufferFormatId())) || wxTheClipboard->IsSupported(wxDF_BITMAP)) { @@ -13472,12 +13468,8 @@ size_t wxRichTextBufferDataObject::GetDataSize() const } } -#if wxUSE_UNICODE wxCharBuffer buffer = bufXML.mb_str(wxConvUTF8); return strlen(buffer) + 1; -#else - return bufXML.Length()+1; -#endif } bool wxRichTextBufferDataObject::GetDataHere(void *pBuf) const @@ -13497,16 +13489,10 @@ bool wxRichTextBufferDataObject::GetDataHere(void *pBuf) const } } -#if wxUSE_UNICODE wxCharBuffer buffer = bufXML.mb_str(wxConvUTF8); size_t len = strlen(buffer); memcpy((char*) pBuf, (const char*) buffer, len); ((char*) pBuf)[len] = 0; -#else - size_t len = bufXML.Length(); - memcpy((char*) pBuf, (const char*) bufXML.c_str(), len); - ((char*) pBuf)[len] = 0; -#endif return true; } diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index c317d6c7e5..4b41f9c279 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -1437,11 +1437,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) GetId()); cmdEvent1.SetEventObject(this); cmdEvent1.SetFlags(flags); -#if wxUSE_UNICODE cmdEvent1.SetCharacter(event.GetUnicodeKey()); -#else - cmdEvent1.SetCharacter((wxChar) keycode); -#endif cmdEvent1.SetPosition(m_caretPosition+1); cmdEvent1.SetContainer(GetFocusObject()); if (GetEventHandler()->ProcessEvent(cmdEvent1) && !cmdEvent1.IsAllowed()) @@ -1454,11 +1450,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetFlags(flags); -#if wxUSE_UNICODE cmdEvent.SetCharacter(event.GetUnicodeKey()); -#else - cmdEvent.SetCharacter((wxChar) keycode); -#endif cmdEvent.SetPosition(m_caretPosition+1); cmdEvent.SetContainer(GetFocusObject()); @@ -1497,11 +1489,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) long newPos = m_caretPosition; DeleteSelectedContent(& newPos); -#if wxUSE_UNICODE wxString str = event.GetUnicodeKey(); -#else - wxString str = (wxChar) event.GetKeyCode(); -#endif GetFocusObject()->InsertTextWithUndo(& GetBuffer(), newPos+1, str, this, 0); EndBatchUndo(); diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index 1a2ac53b73..dd0fee0d46 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -74,7 +74,6 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& wxRichTextDrawingContext context(buffer); buffer->Defragment(context); -#if wxUSE_UNICODE wxCSConv* customEncoding = nullptr; wxMBConv* conv = nullptr; if (!GetEncoding().IsEmpty()) @@ -89,14 +88,9 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& conv = customEncoding; else conv = & wxConvUTF8; -#endif { -#if wxUSE_UNICODE wxTextOutputStream str(stream, wxEOL_NATIVE, *conv); -#else - wxTextOutputStream str(stream, wxEOL_NATIVE); -#endif wxRichTextAttr currentParaStyle = buffer->GetAttributes(); wxRichTextAttr currentCharStyle = buffer->GetAttributes(); @@ -172,10 +166,8 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& str << wxT("\n"); } -#if wxUSE_UNICODE if (customEncoding) delete customEncoding; -#endif m_buffer = nullptr; diff --git a/src/richtext/richtextsymboldlg.cpp b/src/richtext/richtextsymboldlg.cpp index cef53330a0..4e95b82ade 100644 --- a/src/richtext/richtextsymboldlg.cpp +++ b/src/richtext/richtextsymboldlg.cpp @@ -110,7 +110,6 @@ typedef enum } wxUnicodeSubsetCodes; /* Unicode subsets */ -#ifdef __UNICODE__ static struct { @@ -261,8 +260,6 @@ static struct U_SPECIALS, wxT("Specials") } }; -#endif // __UNICODE__ - #if 0 // Not yet used, but could be used to test under Win32 whether this subset is available // for the given font. The Win32 function is allegedly not accurate, however. @@ -289,14 +286,9 @@ wxBEGIN_EVENT_TABLE(wxSymbolPickerDialog, wxDialog) ////@begin wxSymbolPickerDialog event table entries EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_FONT, wxSymbolPickerDialog::OnFontCtrlSelected ) -#if defined(__UNICODE__) EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_SUBSET, wxSymbolPickerDialog::OnSubsetSelected ) EVT_UPDATE_UI( ID_SYMBOLPICKERDIALOG_SUBSET, wxSymbolPickerDialog::OnSymbolpickerdialogSubsetUpdate ) -#endif - -#if defined(__UNICODE__) EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_FROM, wxSymbolPickerDialog::OnFromUnicodeSelected ) -#endif EVT_UPDATE_UI( wxID_OK, wxSymbolPickerDialog::OnOkUpdate ) EVT_BUTTON( wxID_HELP, wxSymbolPickerDialog::OnHelpClick ) @@ -355,15 +347,11 @@ void wxSymbolPickerDialog::Init() ////@begin wxSymbolPickerDialog member initialisation m_fromUnicode = true; m_fontCtrl = nullptr; -#if defined(__UNICODE__) m_subsetCtrl = nullptr; -#endif m_symbolsCtrl = nullptr; m_symbolStaticCtrl = nullptr; m_characterCodeCtrl = nullptr; -#if defined(__UNICODE__) m_fromUnicodeCtrl = nullptr; -#endif m_stdButtonSizer = nullptr; ////@end wxSymbolPickerDialog member initialisation m_dontUpdate = false; @@ -406,13 +394,9 @@ void wxSymbolPickerDialog::CreateControls() itemBoxSizer5->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#if defined(__UNICODE__) wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Subset:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#endif - -#if defined(__UNICODE__) wxArrayString m_subsetCtrlStrings; m_subsetCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_SUBSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_subsetCtrlStrings, wxCB_READONLY ); m_subsetCtrl->SetHelpText(_("Shows a Unicode subset.")); @@ -420,8 +404,6 @@ void wxSymbolPickerDialog::CreateControls() m_subsetCtrl->SetToolTip(_("Shows a Unicode subset.")); itemBoxSizer5->Add(m_subsetCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#endif - m_symbolsCtrl = new wxSymbolListCtrl( itemDialog1, ID_SYMBOLPICKERDIALOG_LISTCTRL, wxDefaultPosition, wxSize(500, 200), 0 ); itemBoxSizer3->Add(m_symbolsCtrl, 1, wxGROW|wxALL, 5); @@ -444,13 +426,9 @@ void wxSymbolPickerDialog::CreateControls() itemBoxSizer12->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#if defined(__UNICODE__) wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("&From:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer12->Add(itemStaticText18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#endif - -#if defined(__UNICODE__) wxArrayString m_fromUnicodeCtrlStrings; m_fromUnicodeCtrlStrings.Add(_("ASCII")); m_fromUnicodeCtrlStrings.Add(_("Unicode")); @@ -461,8 +439,6 @@ void wxSymbolPickerDialog::CreateControls() m_fromUnicodeCtrl->SetToolTip(_("The range to show.")); itemBoxSizer12->Add(m_fromUnicodeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); -#endif - m_stdButtonSizer = new wxStdDialogButtonSizer; itemBoxSizer3->Add(m_stdButtonSizer, 0, wxGROW|wxTOP|wxBOTTOM, 5); @@ -514,7 +490,6 @@ bool wxSymbolPickerDialog::TransferDataToWindow() m_fontCtrl->SetSelection(0); } -#if defined(__UNICODE__) if (m_subsetCtrl->GetCount() == 0) { // Insert items into subset combo @@ -525,11 +500,8 @@ bool wxSymbolPickerDialog::TransferDataToWindow() } m_subsetCtrl->SetSelection(0); } -#endif -#if defined(__UNICODE__) m_symbolsCtrl->SetUnicodeMode(m_fromUnicode); -#endif if (!m_symbol.empty()) { @@ -579,25 +551,19 @@ void wxSymbolPickerDialog::UpdateSymbolDisplay(bool updateSymbolList, bool showA m_characterCodeCtrl->SetValue(wxEmptyString); } -#if defined(__UNICODE__) if (showAtSubset) ShowAtSubset(); -#else - wxUnusedVar(showAtSubset); -#endif } /// Show at the current subset selection void wxSymbolPickerDialog::ShowAtSubset() { -#if defined(__UNICODE__) if (m_fromUnicode) { int sel = m_subsetCtrl->GetSelection(); int low = g_UnicodeSubsetTable[sel].m_low; m_symbolsCtrl->EnsureVisible(low); } -#endif } // Handle font selection @@ -622,7 +588,6 @@ void wxSymbolPickerDialog::OnSymbolSelected( wxCommandEvent& event ) if (sel != wxNOT_FOUND) m_symbol << (wxChar) sel; -#if defined(__UNICODE__) if (sel != -1 && m_fromUnicode) { // Need to make the subset selection reflect the current symbol @@ -638,12 +603,10 @@ void wxSymbolPickerDialog::OnSymbolSelected( wxCommandEvent& event ) } } } -#endif UpdateSymbolDisplay(false, false); } -#if defined(__UNICODE__) // Handle Unicode/ASCII selection void wxSymbolPickerDialog::OnFromUnicodeSelected( wxCommandEvent& WXUNUSED(event) ) { @@ -663,9 +626,6 @@ void wxSymbolPickerDialog::OnSubsetSelected( wxCommandEvent& WXUNUSED(event) ) ShowAtSubset(); } -#endif - -#if defined(__UNICODE__) /*! * wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET @@ -675,7 +635,6 @@ void wxSymbolPickerDialog::OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& ev { event.Enable(m_fromUnicode); } -#endif /*! * wxEVT_UPDATE_UI event handler for wxID_OK @@ -689,16 +648,12 @@ void wxSymbolPickerDialog::OnOkUpdate( wxUpdateUIEvent& event ) /// Set Unicode mode void wxSymbolPickerDialog::SetUnicodeMode(bool unicodeMode) { -#if defined(__UNICODE__) m_dontUpdate = true; m_fromUnicode = unicodeMode; if (m_fromUnicodeCtrl) m_fromUnicodeCtrl->SetSelection(m_fromUnicode ? 1 : 0); UpdateSymbolDisplay(); m_dontUpdate = false; -#else - wxUnusedVar(unicodeMode); -#endif } /// Get the selected symbol character diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index b7e6428ead..4814650ab8 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -32,15 +32,6 @@ #include "wx/stopwatch.h" #include "wx/xml/xml.h" -// For use with earlier versions of wxWidgets -#ifndef WXUNUSED_IN_UNICODE -#if wxUSE_UNICODE -#define WXUNUSED_IN_UNICODE(x) WXUNUSED(x) -#else -#define WXUNUSED_IN_UNICODE(x) x -#endif -#endif - // Set to 1 for slower wxXmlDocument method, 0 for faster direct method. // If we make wxXmlDocument::Save more efficient, we might switch to this // method. @@ -82,10 +73,6 @@ bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& s // This is the encoding to convert to (memory encoding rather than file encoding) wxString encoding(wxT("UTF-8")); -#if !wxUSE_UNICODE && wxUSE_INTL - encoding = wxLocale::GetSystemEncodingName(); -#endif - if (!xmlDoc->Load(stream, encoding)) { buffer->ResetAndClearCommands(); @@ -527,11 +514,7 @@ bool wxRichTextPlainText::ExportXML(wxOutputStream& stream, int indent, wxRichTe } else for (i = 0; i < len; i++) { -#if wxUSE_UNICODE int c = (int) text[i]; -#else - int c = (int) wxUChar(text[i]); -#endif if (((c < 32 || c == 34) && /* c != 9 && */ c != 10 && c != 13) // XML ranges || (!(c >= 32 && c <= 55295) && !(c >= 57344 && c <= 65533)) @@ -638,11 +621,7 @@ bool wxRichTextPlainText::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* han } else for (i = 0; i < len; i++) { -#if wxUSE_UNICODE int c = (int) text[i]; -#else - int c = (int) wxUChar(text[i]); -#endif if ((c < 32 || c == 34) && c != 10 && c != 13) { if (i > 0) @@ -1085,16 +1064,9 @@ void wxRichTextXMLHelper::SetupForSaving(const wxString& enc) { Clear(); -#if wxUSE_UNICODE m_fileEncoding = wxT("UTF-8"); #if wxRICHTEXT_HAVE_DIRECT_OUTPUT m_convFile = & wxConvUTF8; -#endif -#else - m_fileEncoding = wxT("ISO-8859-1"); -#if wxRICHTEXT_HAVE_DIRECT_OUTPUT - m_convFile = & wxConvISO8859_1; -#endif #endif // If we pass an explicit encoding, change the output encoding. @@ -1114,11 +1086,7 @@ void wxRichTextXMLHelper::SetupForSaving(const wxString& enc) // GetSystemEncodingName may not have returned a name if (m_fileEncoding.empty()) -#if wxUSE_UNICODE m_fileEncoding = wxT("UTF-8"); -#else - m_fileEncoding = wxT("ISO-8859-1"); -#endif #if wxRICHTEXT_HAVE_DIRECT_OUTPUT m_convFile = new wxCSConv(m_fileEncoding); m_deleteConvFile = true; @@ -1126,12 +1094,8 @@ void wxRichTextXMLHelper::SetupForSaving(const wxString& enc) } #if wxRICHTEXT_HAVE_DIRECT_OUTPUT -#if !wxUSE_UNICODE - m_convMem = wxConvCurrent; -#else m_convMem = nullptr; #endif -#endif } // Convert a colour to a 6-digit hex string @@ -1271,11 +1235,7 @@ wxString wxRichTextXMLHelper::AttributeToXML(const wxString& str) str1 += str.Mid(last, i - last); wxString s(wxT("&#")); -#if wxUSE_UNICODE s << (int) c; -#else - s << (int) wxUChar(c); -#endif s << wxT(";"); str1 += s; last = i + 1; @@ -1916,10 +1876,9 @@ bool wxRichTextXMLHelper::ImportProperties(wxRichTextProperties& properties, wxX #if wxRICHTEXT_HAVE_DIRECT_OUTPUT // write string to output void wxRichTextXMLHelper::OutputString(wxOutputStream& stream, const wxString& str, - wxMBConv *WXUNUSED_IN_UNICODE(convMem), wxMBConv *convFile) + wxMBConv *WXUNUSED(convMem), wxMBConv *convFile) { if (str.empty()) return; -#if wxUSE_UNICODE if (convFile) { const wxWX2MBbuf buf(str.mb_str(*convFile)); @@ -1930,15 +1889,6 @@ void wxRichTextXMLHelper::OutputString(wxOutputStream& stream, const wxString& s const wxWX2MBbuf buf(str.mb_str(wxConvUTF8)); stream.Write((const char*)buf, strlen((const char*)buf)); } -#else - if ( convFile == nullptr ) - stream.Write(str.mb_str(), str.Len()); - else - { - wxString str2(str.wc_str(*convMem), *convFile); - stream.Write(str2.mb_str(), str2.Len()); - } -#endif } void wxRichTextXMLHelper::OutputIndentation(wxOutputStream& stream, int indent) @@ -1995,11 +1945,7 @@ void wxRichTextXMLHelper::OutputStringEnt(wxOutputStream& stream, const wxString OutputString(stream, str.Mid(last, i - last), convMem, convFile); wxString s(wxT("&#")); -#if wxUSE_UNICODE s << (int) c; -#else - s << (int) wxUChar(c); -#endif s << wxT(";"); OutputString(stream, s, nullptr, nullptr); last = i + 1; diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 7a221de0dc..ea12c5c634 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -660,7 +660,6 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, XYPOSITION * hdc->GetPartialTextExtents(str, tpos); -#if wxUSE_UNICODE // Map the widths back to the UTF-8 input string size_t utf8i = 0; for (size_t wxi = 0; wxi < str.size(); ++wxi) { @@ -687,12 +686,6 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, XYPOSITION * if (c >= 0x10000) positions[utf8i++] = tpos[wxi]; } -#else // !wxUSE_UNICODE - // If not unicode then just use the widths we have - for (int i = 0; i < len; i++) { - positions[i] = tpos[i]; - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE } @@ -3171,12 +3164,8 @@ public: for ( int i = label.length(); curWidth > rect.GetWidth() && i; --i ) { ellipsizedLabel = label.Left(i); - #if wxUSE_UNICODE - // Add the "Horizontal Ellipsis" character (U+2026). - ellipsizedLabel << wxUniChar(0x2026); - #else - ellipsizedLabel << "..."; - #endif + // Add the "Horizontal Ellipsis" character (U+2026). + ellipsizedLabel << wxUniChar(0x2026); buffer = wx2stc(ellipsizedLabel); ellipsizedLen = wx2stclen(ellipsizedLabel, buffer); @@ -3531,8 +3520,6 @@ void Platform::Assert(const char *c, const char *file, int line) { //---------------------------------------------------------------------- -#if wxUSE_UNICODE - // For historical reasons, we use Scintilla-specific conversion functions, we // should probably just call FromUTF8()/utf8_str() directly instead now. @@ -3554,6 +3541,4 @@ wxWX2MBbuf wx2stc(const wxString& str) return str.utf8_str(); } -#endif - #endif // wxUSE_STC diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 9a7e3eb849..992f2b0d5c 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -515,11 +515,10 @@ void ScintillaWX::Paste() { const wxCharBuffer buf(wx2stc(evt.GetString())); -#if wxUSE_UNICODE // free up the old character buffer in case the text is real big text.clear(); data.SetText(text); -#endif + const size_t len = buf.length(); SelectionPosition selStart = sel.IsRectangular() ? sel.Rectangular().Start() : @@ -594,7 +593,7 @@ bool ScintillaWX::CanPaste() { wxTheClipboard->Open(); if (wxTheClipboard->IsOpened()) { - canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); + canPaste = wxTheClipboard->IsSupported(wxDF_UNICODETEXT); if (didOpen) wxTheClipboard->Close(); } @@ -1044,15 +1043,11 @@ void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) { void ScintillaWX::DoAddChar(int key) { -#if wxUSE_UNICODE wxChar wszChars[2]; wszChars[0] = (wxChar)key; wszChars[1] = 0; const wxCharBuffer buf(wx2stc(wszChars)); AddCharUTF(buf, buf.length()); -#else - AddChar((char)key); -#endif } diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 52e022b78d..665444bc97 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -888,13 +888,8 @@ methodOverrideMap = { (0, 0, '''void %s(int codePage) { -#if wxUSE_UNICODE wxASSERT_MSG(codePage == wxSTC_CP_UTF8, - wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); -#else - wxASSERT_MSG(codePage != wxSTC_CP_UTF8, - wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); -#endif + wxT("Only wxSTC_CP_UTF8 may be used.")); SendMsg(%s, codePage);''' ), diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 1a08283c88..7edae5ee0f 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -206,10 +206,8 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_lastKeyDownConsumed = false; m_vScrollBar = nullptr; m_hScrollBar = nullptr; -#if wxUSE_UNICODE // Put Scintilla into unicode (UTF-8) mode SetCodePage(wxSTC_CP_UTF8); -#endif SetInitialSize(size); @@ -587,13 +585,8 @@ int wxStyledTextCtrl::GetNextTabStop(int line, int x) // Set the code page used to interpret the bytes of the document as characters. void wxStyledTextCtrl::SetCodePage(int codePage) { -#if wxUSE_UNICODE wxASSERT_MSG(codePage == wxSTC_CP_UTF8, - wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); -#else - wxASSERT_MSG(codePage != wxSTC_CP_UTF8, - wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); -#endif + wxT("Only wxSTC_CP_UTF8 may be used.")); SendMsg(SCI_SETCODEPAGE, codePage); } @@ -5650,15 +5643,12 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { #endif bool skip = ((ctrl || alt) && ! (ctrl && alt)); -#if wxUSE_UNICODE // apparently if we don't do this, Unicode keys pressed after non-char // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989) if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255) m_lastKeyDownConsumed = false; -#endif if (!m_lastKeyDownConsumed && !skip) { -#if wxUSE_UNICODE int key = evt.GetUnicodeKey(); bool keyOk = true; @@ -5674,13 +5664,6 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { m_swx->DoAddChar(key); return; } -#else - int key = evt.GetKeyCode(); - if (key < WXK_START) { - m_swx->DoAddChar(key); - return; - } -#endif } evt.Skip(); diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index d3067f97d7..db6371dbb4 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -206,10 +206,8 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_lastKeyDownConsumed = false; m_vScrollBar = nullptr; m_hScrollBar = nullptr; -#if wxUSE_UNICODE // Put Scintilla into unicode (UTF-8) mode SetCodePage(wxSTC_CP_UTF8); -#endif SetInitialSize(size); @@ -899,15 +897,12 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { #endif bool skip = ((ctrl || alt) && ! (ctrl && alt)); -#if wxUSE_UNICODE // apparently if we don't do this, Unicode keys pressed after non-char // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989) if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255) m_lastKeyDownConsumed = false; -#endif if (!m_lastKeyDownConsumed && !skip) { -#if wxUSE_UNICODE int key = evt.GetUnicodeKey(); bool keyOk = true; @@ -923,13 +918,6 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { m_swx->DoAddChar(key); return; } -#else - int key = evt.GetKeyCode(); - if (key < WXK_START) { - m_swx->DoAddChar(key); - return; - } -#endif } evt.Skip(); diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index 8618cd64b3..d9f4e726ca 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -4754,9 +4754,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) if ( !event.HasModifiers() ) { int keycode = event.GetKeyCode(); -#if wxUSE_UNICODE wxChar unicode = event.GetUnicodeKey(); -#endif if ( keycode == WXK_RETURN ) { if ( (GetWindowStyle() & wxTE_PROCESS_ENTER) ) @@ -4784,14 +4782,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // skip event.Skip() below return; } -#if wxUSE_UNICODE else if (unicode > 0) { PerformAction(wxACTION_TEXT_INSERT, -1, unicode); return; } -#endif } #if wxDEBUG_LEVEL >= 2 // Ctrl-R refreshes the control in debug mode diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp index 9f2038464a..010fccdd5c 100644 --- a/src/unix/dir.cpp +++ b/src/unix/dir.cpp @@ -128,11 +128,7 @@ bool wxDirData::Read(wxString *filename) if ( !de ) return false; -#if wxUSE_UNICODE de_d_name = wxString(de->d_name, *wxConvFileName); -#else - de_d_name = de->d_name; -#endif // don't return "." and ".." unless asked for if ( de->d_name[0] == '.' && diff --git a/src/unix/mediactrl.cpp b/src/unix/mediactrl.cpp index 17c67a830f..a251ae55c4 100644 --- a/src/unix/mediactrl.cpp +++ b/src/unix/mediactrl.cpp @@ -989,8 +989,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, //init gstreamer // - //Convert arguments to unicode if enabled -#if wxUSE_UNICODE + //Convert arguments to unicode int i; char **argvGST = new char*[wxTheApp->argc + 1]; for ( i = 0; i < wxTheApp->argc; i++ ) @@ -1001,10 +1000,6 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, argvGST[wxTheApp->argc] = nullptr; int argcGST = wxTheApp->argc; -#else -#define argcGST wxTheApp->argc -#define argvGST wxTheApp->argv -#endif //Really init gstreamer gboolean bInited; @@ -1012,14 +1007,12 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, bInited = gst_init_check(&argcGST, &argvGST, &error); // Cleanup arguments for unicode case -#if wxUSE_UNICODE for ( i = 0; i < argcGST; i++ ) { free(argvGST[i]); } delete [] argvGST; -#endif if(!bInited) //gst_init_check fail? { diff --git a/src/unix/mediactrl_gstplayer.cpp b/src/unix/mediactrl_gstplayer.cpp index 7f53a07f0b..3be6dc3227 100644 --- a/src/unix/mediactrl_gstplayer.cpp +++ b/src/unix/mediactrl_gstplayer.cpp @@ -292,8 +292,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, //init gstreamer // - //Convert arguments to unicode if enabled -#if wxUSE_UNICODE + //Convert arguments to unicode int i; char **argvGST = new char*[wxTheApp->argc + 1]; for ( i = 0; i < wxTheApp->argc; i++ ) @@ -304,10 +303,6 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, argvGST[wxTheApp->argc] = nullptr; int argcGST = wxTheApp->argc; -#else -#define argcGST wxTheApp->argc -#define argvGST wxTheApp->argv -#endif //Really init gstreamer gboolean bInited; @@ -315,14 +310,12 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, bInited = gst_init_check(&argcGST, &argvGST, &error); // Cleanup arguments for unicode case -#if wxUSE_UNICODE for ( i = 0; i < argcGST; i++ ) { free(argvGST[i]); } delete [] argvGST; -#endif if(!bInited) //gst_init_check fail? { diff --git a/src/unix/uilocale.cpp b/src/unix/uilocale.cpp index 794f770871..289ee15be0 100644 --- a/src/unix/uilocale.cpp +++ b/src/unix/uilocale.cpp @@ -235,7 +235,6 @@ locale_t TryCreateLocaleWithUTF8(wxLocaleIdent& locId) { locale_t loc = nullptr; -#if wxUSE_UNICODE if ( locId.GetCharset().empty() ) { wxLocaleIdent locIdUTF8(locId); @@ -263,7 +262,6 @@ locale_t TryCreateLocaleWithUTF8(wxLocaleIdent& locId) // if we can't set UTF-8 locale, try non-UTF-8 one: if ( !loc ) -#endif // wxUSE_UNICODE loc = TryCreateLocale(locId); return loc; @@ -356,7 +354,6 @@ static const char *wxSetlocaleTryUTF8(int c, const wxLocaleIdent& locId) // NB: We prefer to set UTF-8 locale if it's possible and only fall back to // non-UTF-8 locale if it fails. -#if wxUSE_UNICODE if ( locId.GetCharset().empty() ) { wxLocaleIdent locIdUTF8(locId); @@ -382,7 +379,6 @@ static const char *wxSetlocaleTryUTF8(int c, const wxLocaleIdent& locId) // if we can't set UTF-8 locale, try non-UTF-8 one: if ( !l ) -#endif // wxUSE_UNICODE l = wxSetlocale(c, locId.GetName()); return l; diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 80ee5d1738..a40115024e 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -443,7 +443,6 @@ public: } } -#if wxUSE_UNICODE ArgsArray(const wchar_t* const* wargv) { int argc = 0; @@ -457,7 +456,6 @@ public: m_argv[i] = wxSafeConvertWX2MB(wargv[i]).release(); } } -#endif // wxUSE_UNICODE ~ArgsArray() { @@ -504,8 +502,6 @@ long wxExecute(const wxString& command, int flags, wxProcess *process, return wxExecute(argv, flags, process, env); } -#if wxUSE_UNICODE - long wxExecute(const wchar_t* const* wargv, int flags, wxProcess* process, const wxExecuteEnv *env) { @@ -514,8 +510,6 @@ long wxExecute(const wchar_t* const* wargv, int flags, wxProcess* process, return wxExecute(argv, flags, process, env); } -#endif // wxUSE_UNICODE - namespace { diff --git a/src/x11/app.cpp b/src/x11/app.cpp index f43c0d6e66..277e15aabf 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -183,13 +183,11 @@ bool wxApp::Initialize(int& argC, wxChar **argV) if ( !wxAppBase::Initialize(argC, argV) ) return false; -#if wxUSE_UNICODE // Glib's type system required by Pango (deprecated since glib 2.36 but // used to be required, so still call it, it's harmless). wxGCC_WARNING_SUPPRESS(deprecated-declarations) g_type_init(); wxGCC_WARNING_RESTORE() -#endif #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); @@ -708,8 +706,6 @@ bool wxApp::OnInitGui() return true; } -#if wxUSE_UNICODE - #include #include @@ -746,7 +742,6 @@ PangoContext* wxGetPangoContext() g_object_ref(context); return context; } -#endif // wxUSE_UNICODE WXColormap wxApp::GetMainColormap(WXDisplay* display) { diff --git a/src/x11/clipbrd.cpp b/src/x11/clipbrd.cpp index 4253e315fa..f20d4a5782 100644 --- a/src/x11/clipbrd.cpp +++ b/src/x11/clipbrd.cpp @@ -346,11 +346,7 @@ extern "C" void wxClipboardHandleSelectionRequest(XEvent event) atomVector.push_back(XA_IMAGE_TIFF); atomVector.push_back(XA_IMAGE_PNG); -#if wxUSE_UNICODE wxDataFormat dfFormat = wxDF_UNICODETEXT; -#else - wxDataFormat dfFormat = wxDF_TEXT; -#endif for ( unsigned i = 0; i <= atomVector.size(); i++ ) { diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index fe3da17a35..3a671893d0 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -33,12 +33,10 @@ #include "cairo-xlib.h" #endif -#if wxUSE_UNICODE #include "glib.h" #include "pango/pangoxft.h" #include "pango_x.cpp" -#endif //----------------------------------------------------------------------------- // local defines @@ -195,9 +193,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC* owner, wxWindow *window ) m_display = (WXDisplay *) wxGlobalDisplay(); -#if wxUSE_UNICODE m_fontdesc = window->GetFont().GetNativeFontInfo()->description; -#endif int screen = DefaultScreen( (Display*) m_display ); m_cmap = (WXColormap) DefaultColormap( (Display*) m_display, screen ); @@ -231,10 +227,8 @@ void wxWindowDCImpl::Init() m_isScreenDC = false; m_x11window = nullptr; -#if wxUSE_UNICODE m_context = wxTheApp->GetPangoContext(); m_fontdesc = nullptr; -#endif } void wxWindowDCImpl::SetUpDC() @@ -1571,7 +1565,6 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) x = XLOG2DEV(x); y = YLOG2DEV(y); -#if wxUSE_UNICODE PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); @@ -1590,64 +1583,6 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) g_object_unref( G_OBJECT( layout ) ); CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); -#else - XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); - - wxCHECK_RET( xfont, wxT("invalid font") ); - - // First draw a rectangle representing the text background, if a text - // background is specified - if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxBRUSHSTYLE_TRANSPARENT)) - { - // Since X draws from the baseline of the text, must add the text height - int cx = 0; - int cy = 0; - int ascent = 0; - int slen; - int direction, descent; - - slen = strlen(text); - XCharStruct overall_return; - - (void)XTextExtents(xfont, (const char*) text.c_str(), slen, &direction, - &ascent, &descent, &overall_return); - - cx = overall_return.width; - cy = ascent + descent; - m_textBackgroundColour.CalcPixel(m_cmap); - m_textForegroundColour.CalcPixel(m_cmap); - XSetForeground ((Display*) m_display, (GC) m_textGC, m_textBackgroundColour.GetPixel()); - XFillRectangle( (Display*) m_display, (Window) m_x11window, - (GC) m_textGC, x, y, cx, cy ); - XSetForeground ((Display*) m_display, (GC) m_textGC, m_textForegroundColour.GetPixel()); - - } - - XSetFont( (Display*) m_display, (GC) m_textGC, xfont->fid ); -#if !wxUSE_NANOX - // This may be a test for whether the font is 16-bit, but it also - // seems to fail for valid 8-bit fonts too. - if (1) // (xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) -#endif - { - XDrawString( (Display*) m_display, (Window) m_x11window, - (GC) m_textGC, x, y + XFontStructGetAscent(xfont), text.c_str(), text.length() ); - } - -#if 0 - if (m_font.GetUnderlined()) - { - wxCoord ul_y = y + XFontStructGetAscent(font); - if (font->descent > 0) ul_y++; - gdk_draw_line( m_x11window, m_textGC, x, ul_y, x + width, ul_y); - } - - width = wxCoord(width / m_scaleX); - height = wxCoord(height / m_scaleY); - - CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); -#endif -#endif } void wxWindowDCImpl::DoDrawRotatedText(const wxString& text, @@ -1697,7 +1632,6 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx return; } -#if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); if (font) @@ -1722,31 +1656,6 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx if (externalLeading) (*externalLeading) = 0; // ?? g_object_unref( G_OBJECT( layout ) ); -#else - wxFont fontToUse = m_font; - if (font) fontToUse = *font; - - wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") ); - - XFontStruct *xfont = (XFontStruct*) fontToUse.GetFontStruct( m_scaleY, m_display ); - - wxCHECK_RET( xfont, wxT("invalid font") ); - - int direction, ascent, descent2; - XCharStruct overall; - - XTextExtents( xfont, (const char*) string.c_str(), string.length(), &direction, - &ascent, &descent2, &overall); - - if (width) - *width = (wxCoord)( overall.width / m_scaleX ); - if (height) - *height = (wxCoord)((ascent + descent2) / m_scaleY ); - if (descent) - *descent = (wxCoord)(descent2 / m_scaleY ); - if (externalLeading) - *externalLeading = 0; // ?? -#endif } wxCoord wxWindowDCImpl::GetCharWidth() const @@ -1754,7 +1663,6 @@ wxCoord wxWindowDCImpl::GetCharWidth() const // Do not test for DC validity here for the same reasons as in // DoGetTextExtent() above. -#if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); if (m_fontdesc) @@ -1768,20 +1676,6 @@ wxCoord wxWindowDCImpl::GetCharWidth() const g_object_unref( G_OBJECT( layout ) ); return w; -#else - wxCHECK_MSG( m_font.IsOk(), 0, wxT("invalid font") ); - - XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); - - wxCHECK_MSG( xfont, 0, wxT("invalid font") ); - - int direction, ascent, descent; - XCharStruct overall; - - XTextExtents( xfont, "H", 1, &direction, &ascent, &descent, &overall ); - - return (wxCoord)(overall.width / m_scaleX); -#endif } wxCoord wxWindowDCImpl::GetCharHeight() const @@ -1789,7 +1683,6 @@ wxCoord wxWindowDCImpl::GetCharHeight() const // Do not test for DC validity here for the same reasons as in // DoGetTextExtent() above. -#if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); if (m_fontdesc) @@ -1803,20 +1696,6 @@ wxCoord wxWindowDCImpl::GetCharHeight() const g_object_unref( G_OBJECT( layout ) ); return h; -#else - wxCHECK_MSG( m_font.IsOk(), 0, wxT("invalid font") ); - - XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); - - wxCHECK_MSG( xfont, 0, wxT("invalid font") ); - - int direction, ascent, descent; - XCharStruct overall; - - XTextExtents( xfont, "H", 1, &direction, &ascent, &descent, &overall ); - - return (wxCoord)((ascent+descent) / m_scaleY); -#endif } void wxWindowDCImpl::Clear() @@ -1855,9 +1734,7 @@ void wxWindowDCImpl::SetFont( const wxFont &font ) m_font = font; -#if wxUSE_UNICODE m_fontdesc = font.GetNativeFontInfo()->description; -#endif } void wxWindowDCImpl::SetPen( const wxPen &pen ) diff --git a/src/x11/dcscreen.cpp b/src/x11/dcscreen.cpp index a61492f81d..7639507f1d 100644 --- a/src/x11/dcscreen.cpp +++ b/src/x11/dcscreen.cpp @@ -45,10 +45,8 @@ wxScreenDCImpl::wxScreenDCImpl( wxDC* owner ) m_isScreenDC = true; -#if wxUSE_UNICODE m_context = wxTheApp->GetPangoContext(); m_fontdesc = wxNORMAL_FONT->GetNativeFontInfo()->description; -#endif SetUpDC(); diff --git a/src/x11/font.cpp b/src/x11/font.cpp index 7e8d70c28d..833a312cde 100644 --- a/src/x11/font.cpp +++ b/src/x11/font.cpp @@ -74,41 +74,6 @@ static wxFontWeight ParseWeightString(wxString s) return wxFONTWEIGHT_NORMAL; } -#if wxUSE_UNICODE -#else -// ---------------------------------------------------------------------------- -// wxXFont -// ---------------------------------------------------------------------------- - -// For every wxFont, there must be a font for each display and scale requested. -// So these objects are stored in wxFontRefData::m_fonts -class wxXFont : public wxObject -{ -public: - wxXFont(); - virtual ~wxXFont(); - - WXFontStructPtr m_fontStruct; // XFontStruct - WXDisplay* m_display; // XDisplay - int m_scale; // Scale * 100 -}; - -wxXFont::wxXFont() -{ - m_fontStruct = (WXFontStructPtr) 0; - m_display = (WXDisplay*) 0; - m_scale = 100; -} - -wxXFont::~wxXFont() -{ - // Freeing the font used to produce a segv, but - // appears to be OK now (bug fix in X11?) - XFontStruct* fontStruct = (XFontStruct*) m_fontStruct; - XFreeFont((Display*) m_display, fontStruct); -} -#endif - // ---------------------------------------------------------------------------- // wxFontRefData // ---------------------------------------------------------------------------- @@ -133,9 +98,6 @@ public: // from XFLD wxFontRefData(const wxString& fontname); - // dstr - virtual ~wxFontRefData(); - // setters: all of them also take care to modify m_nativeFontInfo if we // have it so as to not lose the information not carried by our fields void SetFractionalPointSize(double pointSize); @@ -175,14 +137,6 @@ protected: wxFontEncoding m_encoding; // Unused in Unicode mode wxNativeFontInfo m_nativeFontInfo; - - void ClearX11Fonts(); - -#if wxUSE_UNICODE -#else - // A list of wxXFonts - wxList m_fonts; -#endif }; #define M_FONTDATA ((wxFontRefData*)m_refData) @@ -212,7 +166,6 @@ void wxFontRefData::Init(int pointSize, m_strikethrough = strikethrough; m_encoding = encoding; -#if wxUSE_UNICODE if ( m_nativeFontInfo.description ) pango_font_description_free(m_nativeFontInfo.description); @@ -248,14 +201,12 @@ void wxFontRefData::Init(int pointSize, m_nativeFontInfo.SetNumericWeight(m_weight); m_nativeFontInfo.SetStyle((wxFontStyle)m_style); m_nativeFontInfo.SetUnderlined(underlined); -#endif // wxUSE_UNICODE SetFractionalPointSize(pointSize); } void wxFontRefData::InitFromNative() { -#if wxUSE_UNICODE // Get native info PangoFontDescription *desc = m_nativeFontInfo.description; @@ -278,92 +229,6 @@ void wxFontRefData::InitFromNative() } m_weight = pango_font_description_get_weight( desc ); -#else // X11 - // get the font parameters from the XLFD - // ------------------------------------- - - m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY); - - wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper(); - if ( !w.empty() && w != wxT('*') ) - m_weight = ParseWeightString(w); - else - m_weight = wxFONTWEIGHT_NORMAL; - - switch ( wxToupper( m_nativeFontInfo. - GetXFontComponent(wxXLFD_SLANT)[0u]).GetValue() ) - { - case wxT('I'): // italique - m_style = wxFONTSTYLE_ITALIC; - break; - - case wxT('O'): // oblique - m_style = wxFONTSTYLE_SLANT; - break; - - default: - m_style = wxFONTSTYLE_NORMAL; - } - - long ptSize; - if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) ) - { - // size in XLFD is in 10 point units - m_pointSize = (int)(ptSize / 10); - } - else - { - m_pointSize = wxDEFAULT_FONT_SIZE; - } - - // examine the spacing: if the font is monospaced, assume wxFONTFAMILY_TELETYPE - // family for compatibility with the old code which used it instead of - // IsFixedWidth() - if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) - { - m_family = wxFONTFAMILY_TELETYPE; - } - else // not monospaceed - { - // don't even try guessing it, it doesn't work for too many fonts - // anyhow - m_family = wxFONTFAMILY_UNKNOWN; - } - - // X fonts are never underlined... - m_underlined = false; - - // deal with font encoding - wxString - registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(), - encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper(); - - if ( registry == wxT("ISO8859") ) - { - int cp; - if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) - { - m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); - } - } - else if ( registry == wxT("MICROSOFT") ) - { - int cp; - if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) - { - m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); - } - } - else if ( registry == wxT("KOI8") ) - { - m_encoding = wxFONTENCODING_KOI8; - } - else // unknown encoding - { - // may be give a warning here? or use wxFontMapper? - m_encoding = wxFONTENCODING_SYSTEM; - } -#endif // Pango/X11 } wxFontRefData::wxFontRefData( const wxFontRefData& data ) @@ -393,35 +258,11 @@ wxFontRefData::wxFontRefData(int size, wxFontFamily family, wxFontStyle style, wxFontRefData::wxFontRefData(const wxString& fontname) { // VZ: FromString() should really work in both cases, doesn't it? -#if wxUSE_UNICODE m_nativeFontInfo.FromString( fontname ); -#else - m_nativeFontInfo.SetXFontName(fontname); -#endif InitFromNative(); } -void wxFontRefData::ClearX11Fonts() -{ -#if wxUSE_UNICODE -#else - wxList::compatibility_iterator node = m_fonts.GetFirst(); - while (node) - { - wxXFont* f = (wxXFont*) node->GetData(); - delete f; - node = node->GetNext(); - } - m_fonts.Clear(); -#endif -} - -wxFontRefData::~wxFontRefData() -{ - ClearX11Fonts(); -} - // ---------------------------------------------------------------------------- // wxFontRefData SetXXX() // ---------------------------------------------------------------------------- @@ -432,9 +273,7 @@ void wxFontRefData::SetFractionalPointSize(double pointSize) m_pointSize = pointSize == wxDEFAULT || pointSize < 1 ? wxDEFAULT_FONT_SIZE : pointSize; -#if wxUSE_UNICODE m_nativeFontInfo.SetFractionalPointSize(m_pointSize); -#endif } void wxFontRefData::SetFamily(wxFontFamily family) @@ -448,7 +287,6 @@ void wxFontRefData::SetStyle(wxFontStyle style) { m_style = style; -#if wxUSE_UNICODE // Get native info PangoFontDescription *desc = m_nativeFontInfo.description; @@ -467,7 +305,6 @@ void wxFontRefData::SetStyle(wxFontStyle style) pango_font_description_set_style( desc, PANGO_STYLE_NORMAL ); break; } -#endif } void wxFontRefData::SetNumericWeight(int weight) @@ -499,9 +336,6 @@ void wxFontRefData::SetEncoding(wxFontEncoding encoding) void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) { - // previously cached fonts shouldn't be used - ClearX11Fonts(); - m_nativeFontInfo = info; m_family = info.GetFamily(); @@ -516,7 +350,6 @@ void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) wxFont::wxFont(const wxNativeFontInfo& info) { -#if wxUSE_UNICODE Create( info.GetPointSize(), info.GetFamily(), info.GetStyle(), @@ -527,9 +360,6 @@ wxFont::wxFont(const wxNativeFontInfo& info) if ( info.GetStrikethrough() ) SetStrikethrough(true); -#else - (void) Create(info.GetXFontName()); -#endif } bool wxFont::Create(int pointSize, @@ -550,10 +380,6 @@ bool wxFont::Create(int pointSize, bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) { -#if wxUSE_UNICODE - wxUnusedVar(enc); -#endif - if( !fontname ) { *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); @@ -562,11 +388,7 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) m_refData = new wxFontRefData(); -#if wxUSE_UNICODE // X font name M_FONTDATA->m_nativeFontInfo.FromString( fontname ); -#else - M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); -#endif wxString tmp; @@ -615,43 +437,6 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) tn.GetNextToken(); // avg width -// Note: font encoding is not used in unicode -#if !wxUSE_UNICODE - // deal with font encoding - M_FONTDATA->m_encoding = enc; - if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) - { - wxString registry = tn.GetNextToken().MakeUpper(), - encoding = tn.GetNextToken().MakeUpper(); - - if ( registry == wxT("ISO8859") ) - { - int cp; - if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) - { - M_FONTDATA->m_encoding = - (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); - } - } - else if ( registry == wxT("MICROSOFT") ) - { - int cp; - if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) - { - M_FONTDATA->m_encoding = - (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); - } - } - else if ( registry == wxT("KOI8") ) - { - M_FONTDATA->m_encoding = wxFONTENCODING_KOI8; - } - //else: unknown encoding - may be give a warning here? - else - return false; - } -#endif - return true; } @@ -750,12 +535,8 @@ wxFontEncoding wxFont::GetEncoding() const { wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); -#if wxUSE_UNICODE // unicode didn't use font encoding return wxFONTENCODING_DEFAULT; -#else - return M_FONTDATA->m_encoding; -#endif } @@ -763,12 +544,6 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const { wxCHECK_MSG( IsOk(), nullptr, wxT("invalid font") ); -#if wxUSE_UNICODE -#else - if ( M_FONTDATA->m_nativeFontInfo.GetXFontName().empty() ) - GetInternalFont(); -#endif - return &(M_FONTDATA->m_nativeFontInfo); } @@ -776,23 +551,7 @@ bool wxFont::IsFixedWidth() const { wxCHECK_MSG( IsOk(), false, wxT("invalid font") ); -#if wxUSE_UNICODE return wxFontBase::IsFixedWidth(); -#else - // Robert, is this right? HasNativeFont doesn't exist. - if ( true ) - // if ( M_FONTDATA->HasNativeFont() ) - { - // the monospace fonts are supposed to have "M" in the spacing field - wxString spacing = M_FONTDATA-> - m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING); - - return spacing.Upper() == wxT('M'); - } - // Unreaceable code for now - // return wxFontBase::IsFixedWidth(); -#endif - } // ---------------------------------------------------------------------------- @@ -893,71 +652,3 @@ bool wxFont::SetPangoAttrs(PangoLayout* layout) const return true; } #endif - -#if !wxUSE_UNICODE - -// ---------------------------------------------------------------------------- -// X11 implementation -// ---------------------------------------------------------------------------- - -// Find an existing, or create a new, XFontStruct -// based on this wxFont and the given scale. Append the -// font to list in the private data for future reference. -wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const -{ - if ( !IsOk() ) - return nullptr; - - long intScale = long(scale * 100.0 + 0.5); // key for wxXFont - int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100; - - // search existing fonts first - wxList::compatibility_iterator node = M_FONTDATA->m_fonts.GetFirst(); - while (node) - { - wxXFont* f = (wxXFont*) node->GetData(); - if ((!display || (f->m_display == display)) && (f->m_scale == intScale)) - return f; - node = node->GetNext(); - } - - wxString xFontName = M_FONTDATA->m_nativeFontInfo.GetXFontName(); - if (xFontName == "-*-*-*-*-*--*-*-*-*-*-*-*-*") - // wxFont constructor not called with native font info parameter => take M_FONTDATA values - xFontName.Clear(); - - // not found, create a new one - XFontStruct *font = (XFontStruct *) - wxLoadQueryNearestFont(pointSize, - M_FONTDATA->m_family, - M_FONTDATA->m_style, - M_FONTDATA->m_weight, - M_FONTDATA->m_underlined, - wxT(""), - M_FONTDATA->m_encoding, - & xFontName); - - if ( !font ) - { - wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") ); - - return nullptr; - } - - wxXFont* f = new wxXFont; - f->m_fontStruct = (WXFontStructPtr)font; - f->m_display = ( display ? display : wxGetDisplay() ); - f->m_scale = intScale; - M_FONTDATA->m_fonts.Append(f); - - return f; -} - -WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const -{ - wxXFont* f = GetInternalFont(scale, display); - - return (f ? f->m_fontStruct : (WXFontStructPtr) 0); -} - -#endif // !wxUSE_UNICODE diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index 0460da9cd4..7ba6c26ad3 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -415,18 +415,11 @@ void wxTopLevelWindowX11::SetTitle(const wxString& title) if (X11GetMainWindow()) { -#if wxUSE_UNICODE // I wonder of e.g. Metacity takes UTF-8 here XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); -#else - XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), - (const char*) title); - XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), - (const char*) title); -#endif } } diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 86bf35834e..7a2ade6944 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -1071,7 +1071,6 @@ int wxWindowX11::GetCharHeight() const wxFont font(GetFont()); wxCHECK_MSG( font.IsOk(), 0, wxT("valid window font needed") ); -#if wxUSE_UNICODE // There should be an easier way. PangoLayout *layout = pango_layout_new( wxTheApp->GetPangoContext() ); pango_layout_set_font_description( layout, font.GetNativeFontInfo()->description ); @@ -1081,17 +1080,6 @@ int wxWindowX11::GetCharHeight() const g_object_unref( G_OBJECT( layout ) ); return h; -#else - WXFontStructPtr pFontStruct = font.GetFontStruct(1.0, wxGlobalDisplay()); - - int direction, ascent, descent; - XCharStruct overall; - XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, - &descent, &overall); - - // return (overall.ascent + overall.descent); - return (ascent + descent); -#endif } int wxWindowX11::GetCharWidth() const @@ -1099,7 +1087,6 @@ int wxWindowX11::GetCharWidth() const wxFont font(GetFont()); wxCHECK_MSG( font.IsOk(), 0, wxT("valid window font needed") ); -#if wxUSE_UNICODE // There should be an easier way. PangoLayout *layout = pango_layout_new( wxTheApp->GetPangoContext() ); pango_layout_set_font_description( layout, font.GetNativeFontInfo()->description ); @@ -1109,16 +1096,6 @@ int wxWindowX11::GetCharWidth() const g_object_unref( G_OBJECT( layout ) ); return w; -#else - WXFontStructPtr pFontStruct = font.GetFontStruct(1.0, wxGlobalDisplay()); - - int direction, ascent, descent; - XCharStruct overall; - XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, - &descent, &overall); - - return overall.width; -#endif } void wxWindowX11::DoGetTextExtent(const wxString& string, @@ -1139,7 +1116,6 @@ void wxWindowX11::DoGetTextExtent(const wxString& string, return; } -#if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( wxTheApp->GetPangoContext() ); PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description; @@ -1164,25 +1140,6 @@ void wxWindowX11::DoGetTextExtent(const wxString& string, if (externalLeading) (*externalLeading) = 0; // ?? g_object_unref( G_OBJECT( layout ) ); -#else - WXFontStructPtr pFontStruct = fontToUse.GetFontStruct(1.0, wxGlobalDisplay()); - - int direction, ascent, descent2; - XCharStruct overall; - int slen = string.length(); - - XTextExtents((XFontStruct*) pFontStruct, (const char*) string.c_str(), slen, - &direction, &ascent, &descent2, &overall); - - if ( x ) - *x = (overall.width); - if ( y ) - *y = (ascent + descent2); - if (descent) - *descent = descent2; - if (externalLeading) - *externalLeading = 0; -#endif } // ---------------------------------------------------------------------------- @@ -1616,11 +1573,7 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win KeySym keySym; (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, nullptr); -#if wxUSE_UNICODE int id = wxUnicodeCharXToWX(keySym); -#else - int id = wxCharCodeXToWX(keySym); -#endif // id may be WXK_xxx code - these are outside ASCII range, so we // can't just use toupper() on id. // Only change this if we want the raw key that was pressed, @@ -1635,9 +1588,7 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win wxevent.m_altDown = XKeyEventAltIsDown(xevent); wxevent.m_metaDown = XKeyEventMetaIsDown(xevent); wxevent.SetEventObject(win); -#if wxUSE_UNICODE wxevent.m_uniChar = id; -#endif wxevent.m_keyCode = id; wxevent.SetTimestamp(XKeyEventGetTime(xevent)); diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 48e297e870..06dc3cc318 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -441,10 +441,6 @@ bool wxXmlDoctype::IsValid() const wxXmlDocument::wxXmlDocument() : m_version(wxS("1.0")), m_fileEncoding(wxS("UTF-8")), m_docNode(nullptr) { -#if !wxUSE_UNICODE - m_encoding = wxS("UTF-8"); -#endif - SetFileType(wxTextFileType_Unix); } @@ -486,9 +482,6 @@ wxXmlDocument& wxXmlDocument::operator=(const wxXmlDocument& doc) void wxXmlDocument::DoCopy(const wxXmlDocument& doc) { m_version = doc.m_version; -#if !wxUSE_UNICODE - m_encoding = doc.m_encoding; -#endif m_fileEncoding = doc.m_fileEncoding; m_doctype = doc.m_doctype; m_fileType = doc.m_fileType; @@ -617,19 +610,6 @@ void wxXmlDocument::AppendToProlog(wxXmlNode *node) static wxString CharToString(wxMBConv *conv, const char *s, size_t len = wxString::npos) { -#if !wxUSE_UNICODE - if ( conv ) - { - // there can be no embedded NULs in this string so we don't need the - // output length, it will be NUL-terminated - const wxWCharBuffer wbuf( - wxConvUTF8.cMB2WC(s, len == wxString::npos ? wxNO_LEN : len, nullptr)); - - return wxString(wbuf, *conv); - } - // else: the string is wanted in UTF-8 -#endif // !wxUSE_UNICODE - wxUnusedVar(conv); return wxString::FromUTF8Unchecked(s, len); } @@ -864,11 +844,7 @@ static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData), bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int flags) { -#if wxUSE_UNICODE (void)encoding; -#else - m_encoding = encoding; -#endif const size_t BUFSIZE = 1024; char buf[BUFSIZE]; @@ -879,10 +855,6 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int fl ctx.encoding = wxS("UTF-8"); // default in absence of encoding="" ctx.conv = nullptr; -#if !wxUSE_UNICODE - if ( encoding.CmpNoCase(wxS("UTF-8")) != 0 ) - ctx.conv = new wxCSConv(encoding); -#endif ctx.doctype = &m_doctype; ctx.removeWhiteOnlyNodes = (flags & wxXMLDOC_KEEP_WHITESPACE_NODES) == 0; ctx.parser = parser; @@ -929,10 +901,6 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int fl } XML_ParserFree(parser); -#if !wxUSE_UNICODE - if ( ctx.conv ) - delete ctx.conv; -#endif return ok; @@ -957,7 +925,6 @@ bool OutputString(wxOutputStream& stream, if (str.empty()) return true; -#if wxUSE_UNICODE wxUnusedVar(convMem); if ( !convFile ) convFile = &wxConvUTF8; @@ -971,17 +938,6 @@ bool OutputString(wxOutputStream& stream, } stream.Write(buf, buf.length()); -#else // !wxUSE_UNICODE - if ( convFile && convMem ) - { - wxString str2(str.wc_str(*convMem), *convFile); - stream.Write(str2.mb_str(), str2.length()); - } - else // no conversions to do - { - stream.Write(str.mb_str(), str.length()); - } -#endif // wxUSE_UNICODE/!wxUSE_UNICODE return stream.IsOk(); } @@ -1185,16 +1141,7 @@ bool wxXmlDocument::Save(wxOutputStream& stream, int indentstep) const wxScopedPtr convMem, convFile; -#if wxUSE_UNICODE convFile.reset(new wxCSConv(GetFileEncoding())); -#else - if ( GetFileEncoding().CmpNoCase(GetEncoding()) != 0 ) - { - convFile.reset(new wxCSConv(GetFileEncoding())); - convMem.reset(new wxCSConv(GetEncoding())); - } - //else: file and in-memory encodings are the same, no conversion needed -#endif wxString dec = wxString::Format( wxS("") + m_eol, diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index f62357f500..cf56be402d 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -758,15 +758,6 @@ wxXmlDocument *wxXmlResource::DoLoadFile(const wxString& filename) } wxString encoding(wxT("UTF-8")); -#if !wxUSE_UNICODE && wxUSE_INTL - if ( (GetFlags() & wxXRC_USE_LOCALE) == 0 ) - { - // In case we are not using wxLocale to translate strings, convert the - // strings GUI's charset. This must not be done when wxXRC_USE_LOCALE - // is on, because it could break wxGetTranslation lookup. - encoding = wxLocale::GetSystemEncodingName(); - } -#endif wxScopedPtr doc(new wxXmlDocument); if (!doc->Load(*stream, encoding)) @@ -1655,13 +1646,7 @@ wxString wxXmlResourceHandlerImpl::GetNodeText(const wxXmlNode* node, int flags) } else { -#if wxUSE_UNICODE return str2; -#else - // The string is internally stored as UTF-8, we have to convert - // it into system's default encoding so that it can be displayed: - return wxString(str2.wc_str(wxConvUTF8), wxConvLocal); -#endif } } diff --git a/tests/allheaders.cpp b/tests/allheaders.cpp index f83080a92b..69ba5e122c 100644 --- a/tests/allheaders.cpp +++ b/tests/allheaders.cpp @@ -359,10 +359,9 @@ #endif // clang -// ANSI build hasn't been updated to work without implicit wxString encoding -// and never will be, as it will be removed soon anyhow. And in UTF-8-only -// build we actually want to use implicit encoding (UTF-8). -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +// UTF-8-only build is the only one in which we actually want to use implicit +// encoding (UTF-8). +#if !wxUSE_UTF8_LOCALE_ONLY #define wxNO_IMPLICIT_WXSTRING_ENCODING #endif diff --git a/tests/any/anytest.cpp b/tests/any/anytest.cpp index c7cb0e0543..0e79561596 100644 --- a/tests/any/anytest.cpp +++ b/tests/any/anytest.cpp @@ -570,9 +570,7 @@ void wxAnyTestCase::wxVariantConversions() res = any.GetAs(&variant); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(variant.GetType() == "string"); -#if wxUSE_UNICODE CPPUNIT_ASSERT(variant.GetString() == L"ABC"); -#endif any = vDouble; double d = any.As(); diff --git a/tests/benchmarks/htmlparser/htmlpars.cpp b/tests/benchmarks/htmlparser/htmlpars.cpp index 6121d8d5fe..375b94b968 100644 --- a/tests/benchmarks/htmlparser/htmlpars.cpp +++ b/tests/benchmarks/htmlparser/htmlpars.cpp @@ -452,35 +452,16 @@ void wx28HtmlTagHandler::ParseInnerSource(const wxString& source) wxIMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject); wx28HtmlEntitiesParser::wx28HtmlEntitiesParser() -#if !wxUSE_UNICODE - : m_conv(nullptr), m_encoding(wxFONTENCODING_SYSTEM) -#endif { } wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser() { -#if !wxUSE_UNICODE - delete m_conv; -#endif } void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) { -#if !wxUSE_UNICODE - if (encoding == m_encoding) - return; - - delete m_conv; - - m_encoding = encoding; - if (m_encoding == wxFONTENCODING_SYSTEM) - m_conv = nullptr; - else - m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding)); -#else (void) encoding; -#endif } wxString wx28HtmlEntitiesParser::Parse(const wxString& input) @@ -542,20 +523,6 @@ extern "C" int LINKAGEMODE wx28HtmlEntityCompare(const void *key, const void *it return wxStrcmp((wxChar*)key, ((wx28HtmlEntityInfo*)item)->name); } -#if !wxUSE_UNICODE -wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code) -{ - char buf[2]; - wchar_t wbuf[2]; - wbuf[0] = (wchar_t)code; - wbuf[1] = 0; - wxMBConv *conv = m_conv ? m_conv : &wxConvLocal; - if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) - return '?'; - return buf[0]; -} -#endif - wxChar wx28HtmlEntitiesParser::GetEntityChar(const wxString& entity) { unsigned code = 0; diff --git a/tests/benchmarks/htmlparser/htmlpars.h b/tests/benchmarks/htmlparser/htmlpars.h index 63d619bc35..053826d495 100644 --- a/tests/benchmarks/htmlparser/htmlpars.h +++ b/tests/benchmarks/htmlparser/htmlpars.h @@ -249,7 +249,7 @@ public: virtual ~wx28HtmlEntitiesParser(); // Sets encoding of output string. - // Has no effect if wxUSE_UNICODE==1 + // Has no effect any more. void SetEncoding(wxFontEncoding encoding); // Parses entities in input and replaces them with respective characters @@ -260,18 +260,9 @@ public: wxChar GetEntityChar(const wxString& entity); // Returns character that represents given Unicode code -#if wxUSE_UNICODE wxChar GetCharForCode(unsigned code) { return (wxChar)code; } -#else - wxChar GetCharForCode(unsigned code); -#endif protected: -#if !wxUSE_UNICODE - wxMBConv *m_conv; - wxFontEncoding m_encoding; -#endif - wxDECLARE_NO_COPY_CLASS(wx28HtmlEntitiesParser); }; diff --git a/tests/benchmarks/printfbench.cpp b/tests/benchmarks/printfbench.cpp index e2511591bb..d69c5f9208 100644 --- a/tests/benchmarks/printfbench.cpp +++ b/tests/benchmarks/printfbench.cpp @@ -92,11 +92,7 @@ const wxString g_verylongString = // we need to avoid the use of wxPrintf() here since it could have been mapped // to wxWidgets' implementation of wxVsnPrintf() ! -#if wxUSE_UNICODE - #define sys_printf swprintf -#else - #define sys_printf snprintf -#endif +#define sys_printf swprintf // ---------------------------------------------------------------------------- diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 31bd6f89db..e0e22353d9 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -979,10 +979,8 @@ void DateTimeTestCase::TestTimeZoneParse() { "09:07-04:30", true }, { "19:22+05:45", true }, -#if wxUSE_UNICODE // Containing minus sign (U+2212) as separator between time and tz. { "09:37" "\xe2\x88\x92" "0400", true }, -#endif // Some invalid ones too. diff --git a/tests/events/keyboard.cpp b/tests/events/keyboard.cpp index c88616fa41..0b66a58bfb 100644 --- a/tests/events/keyboard.cpp +++ b/tests/events/keyboard.cpp @@ -161,7 +161,6 @@ void TestEvent(int line, const wxKeyEvent& ev, const KeyDesc& desc) desc.m_keycode, ev.GetKeyCode() ); -#if wxUSE_UNICODE if ( desc.m_keycode < WXK_START ) { // For Latin-1 our key code is the same as Unicode character value. @@ -176,7 +175,6 @@ void TestEvent(int line, const wxKeyEvent& ev, const KeyDesc& desc) 0, (int)ev.GetUnicodeKey() ); } -#endif // wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL_MESSAGE( "wrong modifiers in " + msg, desc.m_mods, diff --git a/tests/events/timertest.cpp b/tests/events/timertest.cpp index d2a7553811..69bac09d32 100644 --- a/tests/events/timertest.cpp +++ b/tests/events/timertest.cpp @@ -111,10 +111,6 @@ void TimerEventTestCase::OneShot() void TimerEventTestCase::Multiple() { - // FIXME: This test crashes on wxGTK ANSI build slave for unknown reason, - // disable it here to let the rest of the test suite run until this - // can be fixed. -#if !defined(__WXGTK__) || wxUSE_UNICODE wxEventLoop loop; TimerCounterHandler handler; @@ -140,5 +136,4 @@ void TimerEventTestCase::Multiple() // parallel actually) it may be much less than 20 so just check that we get // more than one CPPUNIT_ASSERT( numTicks > 1 ); -#endif // !(wxGTK Unicode) } diff --git a/tests/file/filefn.cpp b/tests/file/filefn.cpp index cc4a896ddc..d6e9561326 100644 --- a/tests/file/filefn.cpp +++ b/tests/file/filefn.cpp @@ -46,9 +46,7 @@ protected: const wxString& destFilePath); wxString m_fileNameASCII; -#if wxUSE_UNICODE wxString m_fileNameNonASCII; -#endif // wxUSE_UNICODE wxString m_fileNameWork; wxDECLARE_NO_COPY_CLASS(FileFunctionsTestCase); @@ -65,12 +63,10 @@ FileFunctionsTestCase::FileFunctionsTestCase() wxFileName fn1(wxFileName::GetTempDir(), wxT("wx_file_mask.txt")); m_fileNameASCII = fn1.GetFullPath(); -#if wxUSE_UNICODE // This file name is 'wx_file_mask.txt' in Russian. wxFileName fn2(wxFileName::GetTempDir(), wxT("wx_\u043C\u0430\u0441\u043A\u0430_\u0444\u0430\u0439\u043B\u0430.txt")); m_fileNameNonASCII = fn2.GetFullPath(); -#endif // wxUSE_UNICODE wxFileName fn3(wxFileName::GetTempDir(), wxT("wx_test_copy")); m_fileNameWork = fn3.GetFullPath(); @@ -83,12 +79,10 @@ FileFunctionsTestCase::~FileFunctionsTestCase() { wxRemoveFile(m_fileNameASCII); } -#if wxUSE_UNICODE if ( wxFileExists(m_fileNameNonASCII) ) { wxRemoveFile(m_fileNameNonASCII); } -#endif // wxUSE_UNICODE if ( wxFileExists(m_fileNameWork) ) { wxRemoveFile(m_fileNameWork); @@ -143,10 +137,8 @@ TEST_CASE_METHOD(FileFunctionsTestCase, { // Create file name containing ASCII characters only. DoCreateFile(m_fileNameASCII); -#if wxUSE_UNICODE // Create file name containing non-ASCII characters. DoCreateFile(m_fileNameNonASCII); -#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoCreateFile(const wxString& filePath) @@ -170,10 +162,8 @@ TEST_CASE_METHOD(FileFunctionsTestCase, // Check file name containing ASCII characters only. DoFileExists(m_fileNameASCII); -#if wxUSE_UNICODE // Check file name containing non-ASCII characters. DoFileExists(m_fileNameNonASCII); -#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFileExists(const wxString& filePath) @@ -198,10 +188,8 @@ TEST_CASE_METHOD(FileFunctionsTestCase, { // Find file name containing ASCII characters only. DoFindFile(m_fileNameASCII); -#if wxUSE_UNICODE // Find file name containing non-ASCII characters. DoFindFile(m_fileNameNonASCII); -#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFindFile(const wxString& filePath) @@ -264,10 +252,8 @@ TEST_CASE_METHOD(FileFunctionsTestCase, { // Create & remove file with name containing ASCII characters only. DoRemoveFile(m_fileNameASCII); -#if wxUSE_UNICODE // Create & remove file with name containing non-ASCII characters. DoRemoveFile(m_fileNameNonASCII); -#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoRemoveFile(const wxString& filePath) @@ -290,7 +276,6 @@ TEST_CASE_METHOD(FileFunctionsTestCase, { // Verify renaming file with/without overwriting // when new file already exist/don't exist. -#if wxUSE_UNICODE DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, false); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, true); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, true, false); @@ -299,7 +284,6 @@ TEST_CASE_METHOD(FileFunctionsTestCase, DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, false, true); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, false); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, true); -#endif // wxUSE_UNICODE } void @@ -365,10 +349,8 @@ TEST_CASE_METHOD(FileFunctionsTestCase, "FileFunctions::ConcatenateFiles", "[filefn]") { -#if wxUSE_UNICODE DoConcatFile(m_fileNameASCII, m_fileNameNonASCII, m_fileNameWork); DoConcatFile(m_fileNameNonASCII, m_fileNameASCII, m_fileNameWork); -#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoConcatFile(const wxString& filePath1, @@ -514,28 +496,24 @@ TEST_CASE_METHOD(FileFunctionsTestCase, "FileFunctions::Mkdir", "[filefn]") { -#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxMkdir_test_dir_with_\xc3\xb6"); INFO("Dir: " << dirname); CHECK( wxMkdir(dirname) ); CHECK( wxDirExists(dirname) ); CHECK( wxRmdir(dirname) ); -#endif // wxUSE_UNICODE } TEST_CASE_METHOD(FileFunctionsTestCase, "FileFunctions::Rmdir", "[filefn]") { -#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxRmdir_test_dir_with_\xc3\xb6"); INFO("Dir: " << dirname); CHECK( wxMkdir(dirname) ); CHECK( wxRmdir(dirname) ); CHECK( !wxDirExists(dirname) ); -#endif // wxUSE_UNICODE } /* diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index e08eadd4b1..c2483b9afe 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -31,20 +31,16 @@ public: private: CPPUNIT_TEST_SUITE( FileTestCase ); CPPUNIT_TEST( ReadAll ); -#if wxUSE_UNICODE CPPUNIT_TEST( RoundTripUTF8 ); CPPUNIT_TEST( RoundTripUTF16 ); CPPUNIT_TEST( RoundTripUTF32 ); -#endif // wxUSE_UNICODE CPPUNIT_TEST( TempFile ); CPPUNIT_TEST_SUITE_END(); void ReadAll(); -#if wxUSE_UNICODE void RoundTripUTF8() { DoRoundTripTest(wxConvUTF8); } void RoundTripUTF16() { DoRoundTripTest(wxMBConvUTF16()); } void RoundTripUTF32() { DoRoundTripTest(wxMBConvUTF32()); } -#endif // wxUSE_UNICODE void DoRoundTripTest(const wxMBConv& conv); void TempFile(); @@ -86,8 +82,6 @@ void FileTestCase::ReadAll() } } -#if wxUSE_UNICODE - void FileTestCase::DoRoundTripTest(const wxMBConv& conv) { TestFile tf; @@ -125,8 +119,6 @@ void FileTestCase::DoRoundTripTest(const wxMBConv& conv) } } -#endif // wxUSE_UNICODE - void FileTestCase::TempFile() { wxTempFile tmpFile; diff --git a/tests/formatconverter/formatconvertertest.cpp b/tests/formatconverter/formatconvertertest.cpp index d244090e3b..4dab3bb0b9 100644 --- a/tests/formatconverter/formatconvertertest.cpp +++ b/tests/formatconverter/formatconvertertest.cpp @@ -305,7 +305,7 @@ void FormatConverterTestCase::check(const wxString& input, CPPUNIT_ASSERT_MESSAGE(string(msg.mb_str()), result == expectedUtf8); #endif // wxUSE_UNICODE_UTF8 -#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#if !wxUSE_UTF8_LOCALE_ONLY result = (const wchar_t*)wxFormatString(input); #if defined(__WINDOWS__) && \ @@ -320,7 +320,7 @@ void FormatConverterTestCase::check(const wxString& input, wxT("', result (wchar_t): '") + result + wxT("', expected: '") + expectedWchar + wxT("'"); CPPUNIT_ASSERT_MESSAGE(string(msg.mb_str()), result == expectedWchar); -#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY +#endif // !wxUSE_UTF8_LOCALE_ONLY } diff --git a/tests/intl/intltest.cpp b/tests/intl/intltest.cpp index 8bc133b397..15cdf77d50 100644 --- a/tests/intl/intltest.cpp +++ b/tests/intl/intltest.cpp @@ -235,10 +235,6 @@ void IntlTestCase::IsAvailable() CPPUNIT_ASSERT_EQUAL( origLocale, setlocale(LC_ALL, nullptr) ); } -// The test may fail in ANSI builds because of unsupported encoding, but we -// don't really care about this build anyhow, so just skip it there. -#if wxUSE_UNICODE - TEST_CASE("wxLocale::Default", "[locale]") { CHECK( wxLocale::IsAvailable(wxLANGUAGE_DEFAULT) ); @@ -248,8 +244,6 @@ TEST_CASE("wxLocale::Default", "[locale]") REQUIRE( loc.Init(wxLANGUAGE_DEFAULT, wxLOCALE_DONT_LOAD_DEFAULT) ); } -#endif // wxUSE_UNICODE - // Under MSW and macOS all the locales used below should be supported, but // under Linux some locales may be unavailable. static inline bool CheckSupported(const wxUILocale& loc, const char* desc) @@ -326,8 +320,6 @@ TEST_CASE("wxUILocale::CompareStrings", "[uilocale]") #endif } - // UTF-8 strings are not supported in ASCII build. -#if wxUSE_UNICODE SECTION("German") { const wxUILocale l(wxLocaleIdent().Language("de").Region("DE")); @@ -364,7 +356,6 @@ TEST_CASE("wxUILocale::CompareStrings", "[uilocale]") CHECK( l.CompareStrings(u8("ä"), "ae") == 1 ); CHECK( l.CompareStrings(u8("ö"), "z" ) == 1 ); } -#endif // wxUSE_UNICODE } // Small helper for making the test below more concise. diff --git a/tests/mbconv/convautotest.cpp b/tests/mbconv/convautotest.cpp index 9e006480f2..0ed139363b 100644 --- a/tests/mbconv/convautotest.cpp +++ b/tests/mbconv/convautotest.cpp @@ -12,9 +12,6 @@ #include "testprec.h" - -#if wxUSE_UNICODE - #include "wx/convauto.h" #include "wx/mstream.h" @@ -304,5 +301,3 @@ void ConvAutoTestCase::StreamFallbackMultibyte() TestTextStream("\x61\x82\xa0\x0A\x83\xc0", 6, line1, line2, wxFONTENCODING_CP932); } - -#endif // wxUSE_UNICODE diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index 3bf203a0ac..5eacdf3593 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -140,7 +140,7 @@ private: int sizeofNull // number of bytes occupied by terminating null in this encoding ); -#if wxUSE_UNICODE && wxUSE_STREAMS +#if wxUSE_STREAMS // use wxTextInputStream to exercise wxMBConv interface // (this reveals some bugs in certain wxMBConv subclasses) void TestStreamDecoder( @@ -1182,7 +1182,7 @@ void MBConvTestCase::TestDecoder( CPPUNIT_ASSERT( ((unsigned char*)outputBuffer.data())[i] == UNINITIALIZED ); } -#if wxUSE_UNICODE && wxUSE_STREAMS +#if wxUSE_STREAMS TestStreamDecoder( wideBuffer, wideChars, multiBuffer, multiBytes, converter ); #endif } @@ -1248,12 +1248,12 @@ void MBConvTestCase::TestEncoder( CPPUNIT_ASSERT( ((unsigned char*)outputBuffer.data())[i] == UNINITIALIZED ); } -#if wxUSE_UNICODE && wxUSE_STREAMS +#if wxUSE_STREAMS TestStreamEncoder( wideBuffer, wideChars, multiBuffer, multiBytes, converter ); #endif } -#if wxUSE_UNICODE && wxUSE_STREAMS +#if wxUSE_STREAMS // use wxTextInputStream to exercise wxMBConv interface // (this reveals some bugs in certain wxMBConv subclasses) void MBConvTestCase::TestStreamDecoder( @@ -1283,7 +1283,7 @@ void MBConvTestCase::TestStreamDecoder( } #endif -#if wxUSE_UNICODE && wxUSE_STREAMS +#if wxUSE_STREAMS // use wxTextInputStream to exercise wxMBConv interface // (this reveals some bugs in certain wxMBConv subclasses) void MBConvTestCase::TestStreamEncoder( diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp index b642475fca..8a18a68fb5 100644 --- a/tests/regex/regextest.cpp +++ b/tests/regex/regextest.cpp @@ -175,9 +175,7 @@ bool RegExTestCase::parseFlags(const wxString& flags) // match options case '^': m_matchFlags |= wxRE_NOTBOL; break; case '$': m_matchFlags |= wxRE_NOTEOL; break; -#if wxUSE_UNICODE case '*': break; -#endif // compile options case '&': m_advanced = m_basic = true; break; case 'b': m_basic = true; break; @@ -468,12 +466,6 @@ CheckRE( const char *expected, ...) { -#if !wxUSE_UNICODE - // Skip tests requiring Unicode support, we can't do anything else. - if ( *data != '\0' && wxString::FromUTF8(data).empty() ) - return; -#endif // wxUSE_UNICODE - vector expected_results; va_list ap; diff --git a/tests/streams/datastreamtest.cpp b/tests/streams/datastreamtest.cpp index 27bf25aa92..a98c3af3ed 100644 --- a/tests/streams/datastreamtest.cpp +++ b/tests/streams/datastreamtest.cpp @@ -248,11 +248,9 @@ void DataStreamTestCase::StringRW() wxString s(wxT("Test1")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); -#if wxUSE_UNICODE s.append(2, wxT('\0')); s.append(wxT("Test2")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); -#endif // wxUSE_UNICODE s = wxString::FromUTF8("\xc3\xbc"); // U+00FC LATIN SMALL LETTER U WITH DIAERESIS CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); diff --git a/tests/streams/sstream.cpp b/tests/streams/sstream.cpp index b22c0b51c5..54c7d39b91 100644 --- a/tests/streams/sstream.cpp +++ b/tests/streams/sstream.cpp @@ -131,7 +131,6 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") wxString str(s); CHECK( wxStringOutputStream(&str).TellO() == len ); -#if wxUSE_UNICODE wxMBConvUTF16 convUTF16; wxStringOutputStream ss16(nullptr, convUTF16); CHECK( ss16.TellO() == 0 ); @@ -144,5 +143,4 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") // The U+2070D character is represented by a surrogate pair in UTF-16. wxString u2070D = wxString::FromUTF8("\xF0\xA0\x9C\x8D"); CHECK( wxStringOutputStream(&u2070D, convUTF16).TellO() == 4 ); -#endif // wxUSE_UNICODE } diff --git a/tests/streams/textstreamtest.cpp b/tests/streams/textstreamtest.cpp index 537d1bf124..3005b30b03 100644 --- a/tests/streams/textstreamtest.cpp +++ b/tests/streams/textstreamtest.cpp @@ -24,9 +24,7 @@ #include "wx/longlong.h" #endif -#if wxUSE_UNICODE - #include "wx/mstream.h" -#endif // wxUSE_UNICODE +#include "wx/mstream.h" #include "testfile.h" @@ -49,13 +47,11 @@ private: CPPUNIT_TEST( TestULongLong ); #endif // wxUSE_LONGLONG -#if wxUSE_UNICODE CPPUNIT_TEST( TestUTF8Input ); CPPUNIT_TEST( TestEmbeddedZerosUTF16LEInput ); CPPUNIT_TEST( TestEmbeddedZerosUTF16BEInput ); CPPUNIT_TEST( TestEmbeddedZerosUTF32LEInput ); CPPUNIT_TEST( TestEmbeddedZerosUTF32BEInput ); -#endif // wxUSE_UNICODE CPPUNIT_TEST_SUITE_END(); void Endline(); @@ -66,7 +62,6 @@ private: void TestULongLong(); #endif // wxUSE_LONGLONG -#if wxUSE_UNICODE void TestUTF8Input(); void TestEmbeddedZerosUTF16LEInput(); void TestEmbeddedZerosUTF16BEInput(); @@ -75,8 +70,6 @@ private: void TestInput(const wxMBConv& conv, const void* encodedText, size_t encodedSize ); -#endif // wxUSE_UNICODE - wxDECLARE_NO_COPY_CLASS(TextStreamTestCase); }; @@ -202,8 +195,6 @@ void TextStreamTestCase::TestULongLong() #endif // wxUSE_LONGLONG -#if wxUSE_UNICODE - static const wchar_t txtWchar[4] = { 0x0041, // LATIN CAPITAL LETTER A @@ -362,5 +353,3 @@ TEST_CASE("wxTextInputStream::GetChar", "[text][input][stream][char]") CHECK( tis.GetInputStream().Eof() ); } } - -#endif // wxUSE_UNICODE diff --git a/tests/strings/crt.cpp b/tests/strings/crt.cpp index 6fefd3e3fc..bdbb747c73 100644 --- a/tests/strings/crt.cpp +++ b/tests/strings/crt.cpp @@ -54,7 +54,6 @@ TEST_CASE("CRT::SetGetEnv", "[crt][getenv][setenv]") #undef TESTVAR_NAME } -#if wxUSE_UNICODE TEST_CASE("CRT::Strchr", "[crt][strchr]") { // test that searching for a wide character in a narrow string simply @@ -67,7 +66,6 @@ TEST_CASE("CRT::Strchr", "[crt][strchr]") CHECK( wxStrchr(wxString::FromUTF8(":-) == \xe2\x98\xba"), static_cast(smiley)) ); } -#endif // wxUSE_UNICODE TEST_CASE("CRT::Strcmp", "[crt][strcmp]") { diff --git a/tests/strings/iostream.cpp b/tests/strings/iostream.cpp index 76539a9be0..562441d61d 100644 --- a/tests/strings/iostream.cpp +++ b/tests/strings/iostream.cpp @@ -52,7 +52,7 @@ void StringIostreamTestCase::Out() s << wxString("hello"); ASSERT_OSTREAM_EQUAL("hello", s); -#if wxUSE_UNICODE && defined(HAVE_WOSTREAM) +#if defined(HAVE_WOSTREAM) std::wostringstream ws; ws << wxString("bye"); ASSERT_WOSTREAM_EQUAL(L"bye", ws); diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index 0486665be8..672429ff09 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -470,12 +470,10 @@ TEST_CASE("StdString::Resize", "[stdstring]") CHECK( s3 == wxT("abcABCdefDEF ") ); CHECK( s4 == wxT("abcABCdefDEFWW") ); -#if wxUSE_UNICODE wxString s = wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"); s.resize(3); CHECK( s == wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8") ); -#endif // wxUSE_UNICODE } TEST_CASE("StdString::Riter", "[stdstring]") @@ -567,12 +565,10 @@ TEST_CASE("StdString::Conversion", "[stdstring]") std::wstring s8(s4); CHECK( s8 == L"hello" ); -#if wxUSE_UNICODE std::string s9("\xF0\x9F\x90\xB1\0\xE7\x8C\xAB", 9); /* U+1F431 U+0000 U+732B */ wxString s10 = wxString::FromUTF8(s9); CHECK( s10.ToStdString(wxConvUTF8) == s9 ); CHECK( s10.utf8_string() == s9 ); -#endif // wxUSE_UNICODE std::string s11("xyz\0\xFF", 5); /* an invalid UTF-8 sequence */ CHECK( "" == wxString::FromUTF8(s11) ); diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index 7bf682272e..13c6f6e14b 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -197,7 +197,6 @@ void StringTestCase::Format() void StringTestCase::FormatUnicode() { -#if wxUSE_UNICODE // At least under FreeBSD vsnprintf(), used by wxString::Format(), doesn't // work with Unicode strings unless a UTF-8 locale is used, so set it. wxLocaleSetter loc("C.UTF-8"); @@ -210,7 +209,6 @@ void StringTestCase::FormatUnicode() wxString expected(fmt); expected.Replace("%i", "1"); CPPUNIT_ASSERT_EQUAL( expected, s ); -#endif // wxUSE_UNICODE } void StringTestCase::Constructors() @@ -221,13 +219,11 @@ void StringTestCase::Constructors() CPPUNIT_ASSERT_EQUAL( "Hell", wxString("Hello", 4) ); CPPUNIT_ASSERT_EQUAL( "Hello", wxString("Hello", 5) ); -#if wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( L"", wxString(L'Z', 0) ); CPPUNIT_ASSERT_EQUAL( L"Z", wxString(L'Z') ); CPPUNIT_ASSERT_EQUAL( L"ZZZZ", wxString(L'Z', 4) ); CPPUNIT_ASSERT_EQUAL( L"Hell", wxString(L"Hello", 4) ); CPPUNIT_ASSERT_EQUAL( L"Hello", wxString(L"Hello", 5) ); -#endif // wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( 0, wxString(wxString(), 17).length() ); @@ -270,9 +266,7 @@ void StringTestCase::StaticConstructors() CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello", 5) ); CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello") ); -#if wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( 2, wxString::FromUTF8("h\xc3\xa9llo", 3).length() ); -#endif // wxUSE_UNICODE //CPPUNIT_ASSERT_EQUAL( 1, wxString::FromUTF8("", 1).length() ); @@ -290,13 +284,11 @@ void StringTestCase::Extraction() CPPUNIT_ASSERT( wxStrcmp( s.substr(3, 5).c_str() , wxT("lo, w") ) == 0 ); CPPUNIT_ASSERT( wxStrcmp( s.substr(3).c_str() , wxT("lo, world!") ) == 0 ); -#if wxUSE_UNICODE static const char *germanUTF8 = "Oberfl\303\244che"; wxString strUnicode(wxString::FromUTF8(germanUTF8)); CPPUNIT_ASSERT( strUnicode.Mid(0, 10) == strUnicode ); CPPUNIT_ASSERT( strUnicode.Mid(7, 2) == "ch" ); -#endif // wxUSE_UNICODE wxString rest; @@ -1035,7 +1027,6 @@ void StringTestCase::StringBuf() void StringTestCase::UTF8Buf() { -#if wxUSE_UNICODE // "czech" in Czech ("cestina"): static const char *textUTF8 = "\304\215e\305\241tina"; static const wchar_t textUTF16[] = {0x10D, 0x65, 0x161, 0x74, 0x69, 0x6E, 0x61, 0}; @@ -1050,7 +1041,6 @@ void StringTestCase::UTF8Buf() buf.SetLength(5); } CPPUNIT_ASSERT(s == wxString(textUTF16, 0, 3)); -#endif // wxUSE_UNICODE } @@ -1171,15 +1161,9 @@ void StringTestCase::BeforeAndAfter() // parts: before the first "=", in between the two "="s and after the last // one. This allows to avoid duplicating the string contents (which has to // be different for Unicode and ANSI builds) in the tests below. -#if wxUSE_UNICODE #define FIRST_PART L"letter" #define MIDDLE_PART L"\xe9;\xe7a" #define LAST_PART L"l\xe0" -#else // !wxUSE_UNICODE - #define FIRST_PART "letter" - #define MIDDLE_PART "e;ca" - #define LAST_PART "la" -#endif // wxUSE_UNICODE/!wxUSE_UNICODE const wxString s(FIRST_PART wxT("=") MIDDLE_PART wxT("=") LAST_PART); @@ -1251,7 +1235,6 @@ void StringTestCase::ScopedBuffers() void StringTestCase::SupplementaryUniChar() { -#if wxUSE_UNICODE // Test wxString(wxUniChar ch, size_t nRepeat = 1), // which is implemented upon assign(size_t n, wxUniChar ch). { @@ -1414,5 +1397,4 @@ void StringTestCase::SupplementaryUniChar() /* Not tested here: find_first_of, find_last_of, find_first_not_of, find_last_not_of */ -#endif } diff --git a/tests/strings/tokenizer.cpp b/tests/strings/tokenizer.cpp index c921e8ec8b..47f7d40728 100644 --- a/tests/strings/tokenizer.cpp +++ b/tests/strings/tokenizer.cpp @@ -251,11 +251,7 @@ void TokenizerTestCase::StrtokCompat() if ( ttd.mode != wxTOKEN_STRTOK ) continue; -#if wxUSE_UNICODE wxWCharBuffer -#else - wxCharBuffer -#endif buf(ttd.str); wxChar *last; wxChar *s = wxStrtok(buf.data(), ttd.delims, &last); diff --git a/tests/strings/unichar.cpp b/tests/strings/unichar.cpp index a88b7a0734..62c5845bb3 100644 --- a/tests/strings/unichar.cpp +++ b/tests/strings/unichar.cpp @@ -98,9 +98,7 @@ private: wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongCompare ); ) wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongCompare ); ) wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharCompare ); ) -#if wxUSE_UNICODE CPPUNIT_TEST( StringCompareIntl ); -#endif // wxUSE_UNICODE CPPUNIT_TEST_SUITE_END(); void CharCompare(); @@ -375,7 +373,6 @@ void UniCharTestCase::StringCompare() CPPUNIT_ASSERT( sb[0] != sa); } -#if wxUSE_UNICODE void UniCharTestCase::StringCompareIntl() { // test string comparison with chars @@ -411,7 +408,6 @@ void UniCharTestCase::StringCompareIntl() CPPUNIT_ASSERT( sa != sb[0]); CPPUNIT_ASSERT( sb[0] != sa); } -#endif // wxUSE_UNICODE #define wxUNICHAR_TEST_INT_COMPARE \ wxUniChar a(aVal); \ diff --git a/tests/strings/unicode.cpp b/tests/strings/unicode.cpp index ac19eed9d6..a1c828ba7f 100644 --- a/tests/strings/unicode.cpp +++ b/tests/strings/unicode.cpp @@ -146,9 +146,7 @@ private: CPPUNIT_TEST( ConversionUTF16 ); CPPUNIT_TEST( ConversionUTF32 ); CPPUNIT_TEST( IsConvOk ); -#if wxUSE_UNICODE CPPUNIT_TEST( Iteration ); -#endif CPPUNIT_TEST_SUITE_END(); void ToFromAscii(); @@ -160,9 +158,7 @@ private: void ConversionUTF16(); void ConversionUTF32(); void IsConvOk(); -#if wxUSE_UNICODE void Iteration(); -#endif wxDECLARE_NO_COPY_CLASS(UnicodeTestCase); }; @@ -201,29 +197,23 @@ void UnicodeTestCase::ConstructorsWithConversion() wxString s1(utf8, wxConvUTF8); -#if wxUSE_UNICODE const wchar_t wchar[] = {0x44,0xE9,0x6A,0xE0,0}; CPPUNIT_ASSERT_EQUAL( wchar, s1 ); wxString s2(wchar); CPPUNIT_ASSERT_EQUAL( wchar, s2 ); CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(utf8), s2 ); -#else - CPPUNIT_ASSERT_EQUAL( utf8, s1 ); -#endif wxString sub(utf8sub, wxConvUTF8); // "Dej" substring wxString s3(utf8, wxConvUTF8, 4); CPPUNIT_ASSERT_EQUAL( sub, s3 ); -#if wxUSE_UNICODE wxString s4(wchar, wxConvUTF8, 3); CPPUNIT_ASSERT_EQUAL( sub, s4 ); // conversion should stop with failure at pos 35 wxString s("\t[pl]open.format.Sformatuj dyskietk\xea=gfloppy %f", wxConvUTF8); CPPUNIT_ASSERT( s.empty() ); -#endif // wxUSE_UNICODE // test using Unicode strings together with char* strings (this must work @@ -242,27 +232,20 @@ void UnicodeTestCase::ConversionFixed() { size_t len; -#if wxUSE_UNICODE wxConvLibc.cWC2MB(L"", 0, &len); -#else // !wxUSE_UNICODE - wxConvLibc.cMB2WC("", 0, &len); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( 0, len ); -#if wxUSE_UNICODE // check that when we convert a fixed number of characters we obtain the // expected return value CPPUNIT_ASSERT_EQUAL( 0, wxConvLibc.ToWChar(nullptr, 0, "", 0) ); CPPUNIT_ASSERT_EQUAL( 1, wxConvLibc.ToWChar(nullptr, 0, "x", 1) ); CPPUNIT_ASSERT_EQUAL( 2, wxConvLibc.ToWChar(nullptr, 0, "x", 2) ); CPPUNIT_ASSERT_EQUAL( 2, wxConvLibc.ToWChar(nullptr, 0, "xy", 2) ); -#endif // wxUSE_UNICODE } void UnicodeTestCase::ConversionWithNULs() { -#if wxUSE_UNICODE static const size_t lenNulString = 10; wxString szTheString(L"The\0String", wxConvLibc, lenNulString); @@ -275,19 +258,6 @@ void UnicodeTestCase::ConversionWithNULs() CPPUNIT_ASSERT_EQUAL( lenNulString, szTheString2.length() ); CPPUNIT_ASSERT( wxTmemcmp(szTheString2.c_str(), L"The\0String", lenNulString) == 0 ); -#else // !wxUSE_UNICODE - wxString szTheString("TheString"); - szTheString.insert(3, 1, '\0'); - wxWCharBuffer theBuffer = szTheString.wc_str(wxConvLibc); - - CPPUNIT_ASSERT( memcmp(theBuffer.data(), L"The\0String", 11 * sizeof(wchar_t)) == 0 ); - - wxString szLocalTheString("TheString"); - szLocalTheString.insert(3, 1, '\0'); - wxWCharBuffer theLocalBuffer = szLocalTheString.wc_str(wxConvLocal); - - CPPUNIT_ASSERT( memcmp(theLocalBuffer.data(), L"The\0String", 11 * sizeof(wchar_t)) == 0 ); -#endif // wxUSE_UNICODE/!wxUSE_UNICODE const char *null4buff = "\0\0\0\0"; wxString null4str(null4buff, 4); @@ -459,7 +429,6 @@ void UnicodeTestCase::IsConvOk() #endif } -#if wxUSE_UNICODE void UnicodeTestCase::Iteration() { // "czech" in Czech ("cestina"): @@ -511,5 +480,3 @@ void UnicodeTestCase::Iteration() } } } -#endif // wxUSE_UNICODE - diff --git a/tests/strings/vsnprintf.cpp b/tests/strings/vsnprintf.cpp index f907a2d974..f5d39ca04b 100644 --- a/tests/strings/vsnprintf.cpp +++ b/tests/strings/vsnprintf.cpp @@ -250,7 +250,6 @@ TEST_CASE_METHOD(VsnprintfTestCase, "Vsnprintf::S", "[vsnprintf]") CMP("abcde", "%.5s", wxT("abcdefghi")); // do the same tests but with Unicode characters: -#if wxUSE_UNICODE // Unicode code points from U+03B1 to U+03B9 are the greek letters alpha-iota; // UTF8 encoding of such code points is 0xCEB1 to 0xCEB9 @@ -280,7 +279,6 @@ TEST_CASE_METHOD(VsnprintfTestCase, "Vsnprintf::S", "[vsnprintf]") CMP_UTF8(ABC " ", "%-5s", ABC); CMP_UTF8(ABCDEFGHI, "%-5s", ABCDEFGHI); CMP_UTF8(ABCDE, "%.5s", ABCDEFGHI); -#endif // wxUSE_UNICODE // test a string which has a NUL character after "ab"; // obviously it should be handled exactly like just as "ab" @@ -399,13 +397,11 @@ void VsnprintfTestCase::DoBigToSmallBuffer(T *buffer, int size) TEST_CASE_METHOD(VsnprintfTestCase, "Vsnprintf::BigToSmallBuffer", "[vsnprintf]") { -#if wxUSE_UNICODE wchar_t bufw[1024], bufw2[16], bufw3[4], bufw4; DoBigToSmallBuffer(bufw, 1024); DoBigToSmallBuffer(bufw2, 16); DoBigToSmallBuffer(bufw3, 4); DoBigToSmallBuffer(&bufw4, 1); -#endif // wxUSE_UNICODE char bufa[1024], bufa2[16], bufa3[4], bufa4; DoBigToSmallBuffer(bufa, 1024); diff --git a/tests/textfile/textfiletest.cpp b/tests/textfile/textfiletest.cpp index 408580184b..8c29aab496 100644 --- a/tests/textfile/textfiletest.cpp +++ b/tests/textfile/textfiletest.cpp @@ -51,10 +51,8 @@ private: CPPUNIT_TEST( ReadMixed ); CPPUNIT_TEST( ReadMixedWithFuzzing ); CPPUNIT_TEST( ReadCRCRLF ); -#if wxUSE_UNICODE CPPUNIT_TEST( ReadUTF8 ); CPPUNIT_TEST( ReadUTF16 ); -#endif // wxUSE_UNICODE CPPUNIT_TEST( ReadBig ); CPPUNIT_TEST_SUITE_END(); @@ -68,10 +66,8 @@ private: void ReadMixed(); void ReadMixedWithFuzzing(); void ReadCRCRLF(); -#if wxUSE_UNICODE void ReadUTF8(); void ReadUTF16(); -#endif // wxUSE_UNICODE void ReadBig(); // return the name of the test file we use @@ -269,8 +265,6 @@ void TextFileTestCase::ReadCRCRLF() CPPUNIT_ASSERT_EQUAL( "foobarbaz", all ); } -#if wxUSE_UNICODE - void TextFileTestCase::ReadUTF8() { CreateTestFile("\xd0\x9f\n" @@ -310,8 +304,6 @@ void TextFileTestCase::ReadUTF16() #endif // wxHAVE_U_ESCAPE } -#endif // wxUSE_UNICODE - void TextFileTestCase::ReadBig() { static const size_t NUM_LINES = 10000; diff --git a/tests/uris/uris.cpp b/tests/uris/uris.cpp index 136b68e4db..2ee0802f8c 100644 --- a/tests/uris/uris.cpp +++ b/tests/uris/uris.cpp @@ -330,7 +330,6 @@ void URITestCase::Unescaping() CPPUNIT_ASSERT_EQUAL( unescaped, wxURI::Unescape(escaped) ); -#if wxUSE_UNICODE escaped = "http://ru.wikipedia.org/wiki/" "%D0%A6%D0%B5%D0%BB%D0%BE%D0%B5_%D1%87%D0%B8%D1%81%D0%BB%D0%BE"; @@ -351,7 +350,6 @@ void URITestCase::Unescaping() L"file://\u043C\u043E\u0439\\\u0444\u0430\u0439\u043B", unescaped ); -#endif // wxUSE_UNICODE } void URITestCase::FileScheme() diff --git a/tests/xlocale/xlocale.cpp b/tests/xlocale/xlocale.cpp index fe41c85ccb..53a887f52c 100644 --- a/tests/xlocale/xlocale.cpp +++ b/tests/xlocale/xlocale.cpp @@ -191,11 +191,7 @@ void XLocaleTestCase::TestStdlibFunctionsWith(const wxXLocale& loc) // NOTE: here go the checks which must pass under _any_ locale "loc"; // checks for specific locales are in TestStdlibFunctions() -#if wxUSE_UNICODE wchar_t* endptr; -#else - char* endptr; -#endif // strtod (don't use decimal separator as it's locale-specific) CPPUNIT_ASSERT_EQUAL( 0.0, wxStrtod_l(wxT("0"), nullptr, loc) ); @@ -267,11 +263,7 @@ void XLocaleTestCase::TestStdlibFunctions() { TestStdlibFunctionsWith(wxCLocale); -#if wxUSE_UNICODE wchar_t* endptr; -#else - char* endptr; -#endif // strtod checks specific for C locale endptr = nullptr; diff --git a/tests/xml/xmltest.cpp b/tests/xml/xmltest.cpp index ea532d98cf..b12f9b6efe 100644 --- a/tests/xml/xmltest.cpp +++ b/tests/xml/xmltest.cpp @@ -181,7 +181,6 @@ void XmlTestCase::LoadSave() CPPUNIT_ASSERT_EQUAL( xmlText, sos.GetString() ); -#if wxUSE_UNICODE const char *utf8xmlText = "\n" "\n" @@ -204,7 +203,6 @@ void XmlTestCase::LoadSave() CPPUNIT_ASSERT( doc.Save(sos8) ); CPPUNIT_ASSERT_EQUAL( wxString(utf8xmlText), wxString(sos8.GetString().ToUTF8()) ); -#endif // wxUSE_UNICODE const char *xmlTextProlog = "\n"