Remove wxUSE_UNICODE checks as they're always true now

Also remove all code guarded by "#if !wxUSE_UNICODE".
This commit is contained in:
Vadim Zeitlin 2022-10-27 02:43:51 +01:00
parent 5c49448c75
commit 4519d8e08a
195 changed files with 400 additions and 3509 deletions

View file

@ -473,11 +473,7 @@ public:
// type of argv parameter of main()) or to "wchar_t **" (for compatibility // type of argv parameter of main()) or to "wchar_t **" (for compatibility
// with Unicode build in previous wx versions and because the command line // with Unicode build in previous wx versions and because the command line
// can, in pr // can, in pr
#if wxUSE_UNICODE
wxCmdLineArgsArray argv; wxCmdLineArgsArray argv;
#else
char **argv;
#endif
protected: protected:
// delete all objects in wxPendingDelete list // delete all objects in wxPendingDelete list
@ -825,7 +821,7 @@ public:
// locale (under Unix UTF-8, capable of representing any Unicode string, is // 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 // almost always used and there is no way to retrieve the Unicode command line
// anyhow). // anyhow).
#if wxUSE_UNICODE && defined(__WINDOWS__) #if defined(__WINDOWS__)
#ifdef __VISUALC__ #ifdef __VISUALC__
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ #define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
int wmain(int argc, wchar_t **argv) \ int wmain(int argc, wchar_t **argv) \

View file

@ -411,26 +411,18 @@ typedef wxWritableCharTypeBuffer<char> wxWritableCharBuffer;
typedef wxWritableCharTypeBuffer<wchar_t> wxWritableWCharBuffer; typedef wxWritableCharTypeBuffer<wchar_t> wxWritableWCharBuffer;
#if wxUSE_UNICODE // Compatibility defines, don't use them in the new code.
#define wxWxCharBuffer wxWCharBuffer #define wxWxCharBuffer wxWCharBuffer
#define wxMB2WXbuf wxWCharBuffer #define wxMB2WXbuf wxWCharBuffer
#define wxWX2MBbuf wxCharBuffer #define wxWX2MBbuf wxCharBuffer
#if wxUSE_UNICODE_WCHAR #if wxUSE_UNICODE_WCHAR
#define wxWC2WXbuf wxChar* #define wxWC2WXbuf wxChar*
#define wxWX2WCbuf wxChar* #define wxWX2WCbuf wxChar*
#elif wxUSE_UNICODE_UTF8 #elif wxUSE_UNICODE_UTF8
#define wxWC2WXbuf wxWCharBuffer #define wxWC2WXbuf wxWCharBuffer
#define wxWX2WCbuf wxWCharBuffer
#endif
#else // ANSI
#define wxWxCharBuffer wxCharBuffer
#define wxMB2WXbuf wxChar*
#define wxWX2MBbuf wxChar*
#define wxWC2WXbuf wxCharBuffer
#define wxWX2WCbuf wxWCharBuffer #define wxWX2WCbuf wxWCharBuffer
#endif // Unicode/ANSI #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// A class for holding growable data buffers (not necessarily strings) // A class for holding growable data buffers (not necessarily strings)

View file

@ -94,11 +94,9 @@ namespace Catch
i != wxs.end(); i != wxs.end();
++i ) ++i )
{ {
#if wxUSE_UNICODE
if ( !iswprint(*i) ) if ( !iswprint(*i) )
s += wxString::Format(wxASCII_STR("\\u%04X"), *i).ToAscii(); s += wxString::Format(wxASCII_STR("\\u%04X"), *i).ToAscii();
else else
#endif // wxUSE_UNICODE
s += *i; s += *i;
} }

View file

@ -106,55 +106,37 @@
#endif /* wxHAVE_TCHAR_SUPPORT */ #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? */ typedef wchar_t wxChar;
typedef wchar_t wxSChar;
#if !wxUSE_UNICODE typedef wchar_t wxUChar;
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 */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* define wxStringCharType */ /* 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*: */ wchar_t* or UTF-8 encoded char*: */
#if wxUSE_UNICODE /* FIXME-UTF8: what would be better place for this? */
/* FIXME-UTF8: what would be better place for this? */ #if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8)
#if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8) #error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8"
#error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8" #endif
#endif #ifndef wxUSE_UTF8_LOCALE_ONLY
#ifndef wxUSE_UTF8_LOCALE_ONLY
#define wxUSE_UTF8_LOCALE_ONLY 0
#endif
#ifndef wxUSE_UNICODE_UTF8
#define wxUSE_UNICODE_UTF8 0
#endif
#if wxUSE_UNICODE_UTF8
#define wxUSE_UNICODE_WCHAR 0
#else
#define wxUSE_UNICODE_WCHAR 1
#endif
#else
#define wxUSE_UNICODE_WCHAR 0
#define wxUSE_UNICODE_UTF8 0
#define wxUSE_UTF8_LOCALE_ONLY 0 #define wxUSE_UTF8_LOCALE_ONLY 0
#endif #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 #ifndef SIZEOF_WCHAR_T
#error "SIZEOF_WCHAR_T must be defined before including this file in wx/defs.h" #error "SIZEOF_WCHAR_T must be defined before including this file in wx/defs.h"
#endif #endif
@ -189,15 +171,11 @@
compatibility. compatibility.
*/ */
#ifndef wxT #ifndef wxT
#if !wxUSE_UNICODE /*
#define wxT(x) x Notice that we use an intermediate macro to allow x to be expanded
#else /* Unicode */ if it's a macro itself.
/* */
Notice that we use an intermediate macro to allow x to be expanded #define wxT(x) wxCONCAT_HELPER(L, x)
if it's a macro itself.
*/
#define wxT(x) wxCONCAT_HELPER(L, x)
#endif /* ASCII/Unicode */
#endif /* !defined(wxT) */ #endif /* !defined(wxT) */
/* /*

View file

@ -370,14 +370,6 @@
# endif # endif
#endif /* !defined(wxUSE_TEXTFILE) */ #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 #ifndef wxUSE_UNSAFE_WXSTRING_CONV
# ifdef wxABORT_ON_CONFIG_ERROR # ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_UNSAFE_WXSTRING_CONV must be defined, please read comment near the top of this file." # error "wxUSE_UNSAFE_WXSTRING_CONV must be defined, please read comment near the top of this file."

View file

@ -16,8 +16,6 @@
// wxCmdLineArgsArray: helper class used by wxApp::argv // wxCmdLineArgsArray: helper class used by wxApp::argv
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE
// this class is used instead of either "char **" or "wchar_t **" (neither of // 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 // which would be backwards compatible with all the existing code) for argv
// field of wxApp // field of wxApp
@ -148,7 +146,5 @@ inline bool operator&&(bool cond, const wxCmdLineArgsArray& array)
return cond && !array.IsEmpty(); return cond && !array.IsEmpty();
} }
#endif // wxUSE_UNICODE
#endif // _WX_CMDARGS_H_ #endif // _WX_CMDARGS_H_

View file

@ -206,11 +206,9 @@ public:
// default ctor or ctor giving the cmd line in either Unix or Win form // default ctor or ctor giving the cmd line in either Unix or Win form
wxCmdLineParser() { Init(); } wxCmdLineParser() { Init(); }
wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); } wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); }
#if wxUSE_UNICODE
wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); } wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); }
wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv) wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); } { Init(); SetCmdLine(argc, argv); }
#endif // wxUSE_UNICODE
wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); } wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); }
// the same as above, but also gives the cmd line description - otherwise, // the same as above, but also gives the cmd line description - otherwise,
@ -219,23 +217,19 @@ public:
{ Init(); SetDesc(desc); } { Init(); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, char **argv) wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, char **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); } { Init(); SetCmdLine(argc, argv); SetDesc(desc); }
#if wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv) wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); } { Init(); SetCmdLine(argc, argv); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, wxCmdLineParser(const wxCmdLineEntryDesc *desc,
int argc, int argc,
const wxCmdLineArgsArray& argv) const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); } { Init(); SetCmdLine(argc, argv); SetDesc(desc); }
#endif // wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline) wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline)
{ Init(); SetCmdLine(cmdline); SetDesc(desc); } { Init(); SetCmdLine(cmdline); SetDesc(desc); }
// set cmd line to parse after using one of the ctors which don't do it // set cmd line to parse after using one of the ctors which don't do it
void SetCmdLine(int argc, char **argv); void SetCmdLine(int argc, char **argv);
#if wxUSE_UNICODE
void SetCmdLine(int argc, wxChar **argv); void SetCmdLine(int argc, wxChar **argv);
void SetCmdLine(int argc, const wxCmdLineArgsArray& argv); void SetCmdLine(int argc, const wxCmdLineArgsArray& argv);
#endif // wxUSE_UNICODE
void SetCmdLine(const wxString& cmdline); void SetCmdLine(const wxString& cmdline);
// not virtual, don't use this class polymorphically // not virtual, don't use this class polymorphically

View file

@ -315,13 +315,11 @@ private:
// wxTextDataObject contains text data // wxTextDataObject contains text data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXQT__)
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXQT__) #define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ
#define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ #elif defined(__WXMAC__)
#elif defined(__WXMAC__) #define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ
#define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ #endif
#endif
#endif // wxUSE_UNICODE
class WXDLLIMPEXP_CORE wxHTMLDataObject : public wxDataObjectSimple class WXDLLIMPEXP_CORE wxHTMLDataObject : public wxDataObjectSimple
{ {
@ -368,13 +366,7 @@ public:
// ctor: you can specify the text here or in SetText(), or override // ctor: you can specify the text here or in SetText(), or override
// GetText() // GetText()
wxTextDataObject(const wxString& text = wxEmptyString) wxTextDataObject(const wxString& text = wxEmptyString)
: wxDataObjectSimple( : wxDataObjectSimple(wxDF_UNICODETEXT),
#if wxUSE_UNICODE
wxDF_UNICODETEXT
#else
wxDF_TEXT
#endif
),
m_text(text) m_text(text)
{ {
} }

View file

@ -45,10 +45,8 @@ public:
} }
#endif // wxUSE_APPLE_IEEE #endif // wxUSE_APPLE_IEEE
#if wxUSE_UNICODE
void SetConv( const wxMBConv &conv ); void SetConv( const wxMBConv &conv );
wxMBConv *GetConv() const { return m_conv; } wxMBConv *GetConv() const { return m_conv; }
#endif
protected: protected:
// Ctor and dtor are both protected, this class is never used directly but // Ctor and dtor are both protected, this class is never used directly but
@ -63,9 +61,7 @@ protected:
bool m_useExtendedPrecision; bool m_useExtendedPrecision;
#endif // wxUSE_APPLE_IEEE #endif // wxUSE_APPLE_IEEE
#if wxUSE_UNICODE
wxMBConv *m_conv; wxMBConv *m_conv;
#endif
wxDECLARE_NO_COPY_CLASS(wxDataStreamBase); wxDECLARE_NO_COPY_CLASS(wxDataStreamBase);
}; };

View file

@ -166,8 +166,6 @@ inline void wxDisableAsserts() { wxSetAssertHandler(nullptr); }
(assert macros do it). (assert macros do it).
*/ */
#if wxUSE_UNICODE
// these overloads are the ones typically used by debugging macros: we have to // 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 // 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 // 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 *func,
const char *cond, const char *cond,
const wxChar *msg) ; const wxChar *msg) ;
#endif /* wxUSE_UNICODE */
// this version is for compatibility with wx 2.8 Unicode build only, we don't // 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 // use it ourselves any more except in ANSI-only build in which case it is all

View file

@ -413,12 +413,17 @@ typedef short int WXTYPE;
/* Very common macros */ /* Very common macros */
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
/* Printf-like attribute definitions to obtain warnings with GNU C/C++ */ /* Printf-like attribute definitions which could be used to obtain warnings
#if defined(__GNUC__) && !wxUSE_UNICODE 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))) # define WX_ATTRIBUTE_FORMAT(like, m, n) __attribute__ ((__format__ (like, m, n)))
#else #else
# define WX_ATTRIBUTE_FORMAT(like, m, n) */
#endif
#define WX_ATTRIBUTE_FORMAT(like, m, n)
#ifndef WX_ATTRIBUTE_PRINTF #ifndef WX_ATTRIBUTE_PRINTF
# define WX_ATTRIBUTE_PRINTF(m, n) WX_ATTRIBUTE_FORMAT(__printf__, m, n) # define WX_ATTRIBUTE_PRINTF(m, n) WX_ATTRIBUTE_FORMAT(__printf__, m, n)
@ -801,12 +806,8 @@ typedef short int WXTYPE;
#define WXUNUSED(identifier) identifier #define WXUNUSED(identifier) identifier
#endif #endif
/* some arguments are not used in unicode mode */ /* Defined for compatibility only. */
#if wxUSE_UNICODE #define WXUNUSED_IN_UNICODE(param) WXUNUSED(param)
#define WXUNUSED_IN_UNICODE(param) WXUNUSED(param)
#else
#define WXUNUSED_IN_UNICODE(param) param
#endif
/* unused parameters in non stream builds */ /* unused parameters in non stream builds */
#if wxUSE_STREAMS #if wxUSE_STREAMS
@ -2987,7 +2988,7 @@ typedef GtkWidget *WXWidget;
#endif /* __WXGTK__ */ #endif /* __WXGTK__ */
#if defined(__WXGTK__) || (defined(__WXX11__) && wxUSE_UNICODE) #if defined(__WXGTK__) || defined(__WXX11__)
#define wxUSE_PANGO 1 #define wxUSE_PANGO 1
#else #else
#define wxUSE_PANGO 0 #define wxUSE_PANGO 0

View file

@ -290,20 +290,14 @@ public:
} }
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// this function is useful for loading functions from the standard Windows // This function is misnamed now as it always loads "W" symbol because we
// DLLs: such functions have an 'A' (in ANSI build) or 'W' (in Unicode, or // always use Unicode now, but keeps its old name for compatibility.
// wide character build) suffix if they take string parameters
static void *RawGetSymbolAorW(wxDllType handle, const wxString& name) static void *RawGetSymbolAorW(wxDllType handle, const wxString& name)
{ {
return RawGetSymbol return RawGetSymbol
( (
handle, handle,
name + name + L'W'
#if wxUSE_UNICODE
L'W'
#else
'A'
#endif
); );
} }

View file

@ -2207,10 +2207,8 @@ public:
// returns true iff this event's key code is of a certain type // returns true iff this event's key code is of a certain type
bool IsKeyInCategory(int category) const; bool IsKeyInCategory(int category) const;
#if wxUSE_UNICODE
// get the Unicode character corresponding to this key // get the Unicode character corresponding to this key
wxChar GetUnicodeKey() const { return m_uniChar; } wxChar GetUnicodeKey() const { return m_uniChar; }
#endif // wxUSE_UNICODE
// get the raw key code (platform-dependent) // get the raw key code (platform-dependent)
wxUint32 GetRawKeyCode() const { return m_rawCode; } wxUint32 GetRawKeyCode() const { return m_rawCode; }
@ -2271,11 +2269,9 @@ public:
long m_keyCode; long m_keyCode;
#if wxUSE_UNICODE
// This contains the full Unicode character // This contains the full Unicode character
// in a character events in Unicode mode // in a character events in Unicode mode
wxChar m_uniChar; wxChar m_uniChar;
#endif
// these fields contain the platform-specific information about // these fields contain the platform-specific information about
// key that was pressed // key that was pressed
@ -2308,9 +2304,7 @@ private:
m_rawCode = evt.m_rawCode; m_rawCode = evt.m_rawCode;
m_rawFlags = evt.m_rawFlags; m_rawFlags = evt.m_rawFlags;
#if wxUSE_UNICODE
m_uniChar = evt.m_uniChar; m_uniChar = evt.m_uniChar;
#endif
m_isRepeat = evt.m_isRepeat; m_isRepeat = evt.m_isRepeat;
} }

View file

@ -246,66 +246,25 @@ enum wxPosixPermissions
#define wxEof wxPOSIX_IDENT(eof) #define wxEof wxPOSIX_IDENT(eof)
// then the functions taking strings // then the functions taking strings
#define wxCRT_Open _wopen
// first the ANSI versions wxDECL_FOR_STRICT_MINGW32(int, _wopen, (const wchar_t*, int, ...))
#define wxCRT_OpenA wxPOSIX_IDENT(open) wxDECL_FOR_STRICT_MINGW32(int, _waccess, (const wchar_t*, int))
#define wxCRT_AccessA wxPOSIX_IDENT(access) wxDECL_FOR_STRICT_MINGW32(int, _wchmod, (const wchar_t*, int))
#define wxCRT_ChmodA wxPOSIX_IDENT(chmod) wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*))
#define wxCRT_MkDirA wxPOSIX_IDENT(mkdir) wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*))
#define wxCRT_RmDirA wxPOSIX_IDENT(rmdir) 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 #ifdef wxHAS_HUGE_FILES
// MinGW-64 provides underscore-less versions of all file functions #define wxCRT_Stat _wstati64
// except for this one.
#ifdef __MINGW64_TOOLCHAIN__
#define wxCRT_StatA _stati64
#else
#define wxCRT_StatA wxPOSIX_IDENT(stati64)
#endif
#else #else
#define wxCRT_StatA wxPOSIX_IDENT(stat) #define wxCRT_Stat _wstat
#endif #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) // constants (unless already defined by the user code)
#ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS

View file

@ -44,20 +44,12 @@ public:
private: private:
static wxString GetAddButtonLabel() static wxString GetAddButtonLabel()
{ {
#if wxUSE_UNICODE
return wchar_t(0xFF0B); // FULLWIDTH PLUS SIGN return wchar_t(0xFF0B); // FULLWIDTH PLUS SIGN
#else
return "+";
#endif
} }
static wxString GetRemoveButtonLabel() static wxString GetRemoveButtonLabel()
{ {
#if wxUSE_UNICODE
return wchar_t(0x2012); // FIGURE DASH return wchar_t(0x2012); // FIGURE DASH
#else
return "-";
#endif
} }
}; };

View file

@ -203,12 +203,6 @@ private:
wxString m_label; wxString m_label;
int m_value; 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: protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer); wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer);
}; };

View file

@ -30,65 +30,15 @@
// and use it only to test for pango versions >= 1.16.0 // 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); 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(s) (s).utf8_str() #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
#define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s)) #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
#define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s)) #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
#define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
#define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s) #define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s)
#define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(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_FONT(s, font) wxGTK_CONV_BACK(s)
#define wxGTK_CONV_BACK_SYS(s) 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 a macro for converting wxString to char* in appropriate encoding for // Define a macro for converting wxString to char* in appropriate encoding for
// the file names. // the file names.

View file

@ -547,10 +547,8 @@ struct WXDLLIMPEXP_BASE wxStringEqual
{ return a == b; } { return a == b; }
bool operator()( const wxChar* a, const wxChar* b ) const noexcept bool operator()( const wxChar* a, const wxChar* b ) const noexcept
{ return wxStrcmp( a, b ) == 0; } { return wxStrcmp( a, b ) == 0; }
#if wxUSE_UNICODE
bool operator()( const char* a, const char* b ) const noexcept bool operator()( const char* a, const char* b ) const noexcept
{ return strcmp( a, b ) == 0; } { return strcmp( a, b ) == 0; }
#endif // wxUSE_UNICODE
}; };
#ifdef wxNEEDS_WX_HASH_MAP #ifdef wxNEEDS_WX_HASH_MAP

View file

@ -270,13 +270,8 @@ public:
wxHtmlEntitiesParser(); wxHtmlEntitiesParser();
virtual ~wxHtmlEntitiesParser(); virtual ~wxHtmlEntitiesParser();
// Sets encoding of output string. // Obsolete, has no effect.
// Has no effect if wxUSE_UNICODE==1
#if wxUSE_UNICODE
void SetEncoding(wxFontEncoding WXUNUSED(encoding)) {} void SetEncoding(wxFontEncoding WXUNUSED(encoding)) {}
#else
void SetEncoding(wxFontEncoding encoding);
#endif
// Parses entities in input and replaces them with respective characters // Parses entities in input and replaces them with respective characters
// (with respect to output encoding) // (with respect to output encoding)
@ -286,18 +281,9 @@ public:
wxChar GetEntityChar(const wxString& entity) const; wxChar GetEntityChar(const wxString& entity) const;
// Returns character that represents given Unicode code // Returns character that represents given Unicode code
#if wxUSE_UNICODE
wxChar GetCharForCode(unsigned code) const { return (wxChar)code; } wxChar GetCharForCode(unsigned code) const { return (wxChar)code; }
#else
wxChar GetCharForCode(unsigned code) const;
#endif
protected: protected:
#if !wxUSE_UNICODE
wxMBConv *m_conv;
wxFontEncoding m_encoding;
#endif
wxDECLARE_NO_COPY_CLASS(wxHtmlEntitiesParser); wxDECLARE_NO_COPY_CLASS(wxHtmlEntitiesParser);
}; };

View file

@ -142,13 +142,6 @@ public:
// following space as being part of the same space run as before. // following space as being part of the same space run as before.
void StopCollapsingSpaces() { m_tmpLastWasSpace = false; } 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. // creates font depending on m_Font* members.
virtual wxFont* CreateCurrentFont(); virtual wxFont* CreateCurrentFont();
@ -210,9 +203,6 @@ private:
wxFont* m_FontsTable[2][2][2][2][7]; wxFont* m_FontsTable[2][2][2][2][7];
wxString m_FontsFacesTable[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 // table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off
// state of these flags (from left to right): // state of these flags (from left to right):
// [bold][italic][underlined][fixed_size] // [bold][italic][underlined][fixed_size]
@ -223,13 +213,6 @@ private:
wxString m_FontFaceFixed, m_FontFaceNormal; wxString m_FontFaceFixed, m_FontFaceNormal;
// html font sizes and faces of fixed and proportional fonts // 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 // current whitespace handling mode
WhitespaceMode m_whitespaceMode; WhitespaceMode m_whitespaceMode;

View file

@ -139,8 +139,7 @@ typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&);
#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__) #if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/hyperlink.h" #include "wx/gtk/hyperlink.h"
// Note that the native control is only available in Unicode version under MSW. #elif defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__)
#include "wx/msw/hyperlink.h" #include "wx/msw/hyperlink.h"
#else #else
#include "wx/generic/hyperlink.h" #include "wx/generic/hyperlink.h"

View file

@ -45,13 +45,9 @@ extern void WXDLLIMPEXP_BASE wxEntryCleanup();
extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv); extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv);
// we overload wxEntry[Start]() to take "char **" pointers too // we overload wxEntry[Start]() to take "char **" pointers too
#if wxUSE_UNICODE
extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv); extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv);
extern int WXDLLIMPEXP_BASE wxEntry(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 // Under Windows we define additional wxEntry() overloads with signature
// compatible with WinMain() and not the traditional main(). // compatible with WinMain() and not the traditional main().
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -68,9 +64,7 @@ extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv);
// call to wxInitialize() must be matched by wxUninitialize()) // call to wxInitialize() must be matched by wxUninitialize())
extern bool WXDLLIMPEXP_BASE wxInitialize(); extern bool WXDLLIMPEXP_BASE wxInitialize();
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, wxChar **argv); extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, wxChar **argv);
#if wxUSE_UNICODE
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, char **argv); 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 // clean up -- the library can't be used any more after the last call to
// wxUninitialize() // wxUninitialize()
@ -92,12 +86,10 @@ public:
m_ok = wxInitialize(argc, argv); m_ok = wxInitialize(argc, argv);
} }
#if wxUSE_UNICODE
wxInitializer(int& argc, char **argv) wxInitializer(int& argc, char **argv)
{ {
m_ok = wxInitialize(argc, argv); m_ok = wxInitialize(argc, argv);
} }
#endif // wxUSE_UNICODE
// has the initialization been successful? (explicit test) // has the initialization been successful? (explicit test)
bool IsOk() const { return m_ok; } bool IsOk() const { return m_ok; }

View file

@ -25,12 +25,7 @@
without them being defined, better give a clearer error right now. without them being defined, better give a clearer error right now.
*/ */
#if !defined(UNICODE) #if !defined(UNICODE)
#ifndef wxUSE_UNICODE #error "UNICODE must be defined before including this header."
#error "wxUSE_UNICODE must be defined before including this header."
#endif
#if wxUSE_UNICODE
#error "UNICODE must be defined before including this header."
#endif
#endif #endif
/* /*

View file

@ -17,7 +17,7 @@
// TD_WARNING_ICON being defined in the headers for this as this symbol is used // 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 // by the task dialogs only. Also notice that task dialogs are available for
// Unicode applications only. // Unicode applications only.
#if defined(TD_WARNING_ICON) && wxUSE_UNICODE #if defined(TD_WARNING_ICON)
#define wxHAS_MSW_TASKDIALOG #define wxHAS_MSW_TASKDIALOG
#endif #endif

View file

@ -21,11 +21,7 @@ struct _EXCEPTION_POINTERS;
struct _SYMBOL_INFO; struct _SYMBOL_INFO;
struct _SYMBOL_INFOW; struct _SYMBOL_INFOW;
#if wxUSE_UNICODE #define wxSYMBOL_INFO _SYMBOL_INFOW
#define wxSYMBOL_INFO _SYMBOL_INFOW
#else // !wxUSE_UNICODE
#define wxSYMBOL_INFO _SYMBOL_INFO
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStackFrame // wxStackFrame

View file

@ -220,15 +220,6 @@ protected:
// the limit is due to a previous call to SetMaxLength() and not built in) // the limit is due to a previous call to SetMaxLength() and not built in)
bool HasSpaceLimit(unsigned int *len) const; 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 // replace the contents of the selection or of the entire control with the
// given text // given text
void DoWriteText(const wxString& text, void DoWriteText(const wxString& text,

View file

@ -176,48 +176,9 @@ public:
// Trivial default ctor. // Trivial default ctor.
wxUxThemeFont() { } wxUxThemeFont() { }
#if wxUSE_UNICODE // This class is now completely trivial and should be removed.
// In Unicode build we always use LOGFONT anyhow so this class is
// completely trivial.
LPLOGFONTW GetPtr() { return &m_lfW; } LPLOGFONTW GetPtr() { return &m_lfW; }
const LOGFONTW& GetLOGFONT() { 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<LPLOGFONTW>(&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: private:
LOGFONTW m_lfW; LOGFONTW m_lfW;

View file

@ -21,7 +21,7 @@
// Set Unicode format for a common control // Set Unicode format for a common control
inline void wxSetCCUnicodeFormat(HWND hwnd) inline void wxSetCCUnicodeFormat(HWND hwnd)
{ {
::SendMessage(hwnd, CCM_SETUNICODEFORMAT, wxUSE_UNICODE, 0); ::SendMessage(hwnd, CCM_SETUNICODEFORMAT, TRUE, 0);
} }
#if wxUSE_GUI #if wxUSE_GUI

View file

@ -493,8 +493,7 @@
/* /*
check the consistency of the settings in setup.h: note that this must be 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 done after defining the compiler macros used in wx/chkconf.h
and after defining the compiler macros which are used in it too
*/ */
#include "wx/chkconf.h" #include "wx/chkconf.h"

View file

@ -428,7 +428,6 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
break; break;
case wxT('c'): case wxT('c'):
#if wxUSE_UNICODE
if (ilen == -1) if (ilen == -1)
{ {
// %hc == ANSI character // %hc == ANSI character
@ -439,23 +438,10 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
// %lc == %c == Unicode character // %lc == %c == Unicode character
m_type = wxPAT_WCHAR; 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; done = true;
break; break;
case wxT('s'): case wxT('s'):
#if wxUSE_UNICODE
if (ilen == -1) if (ilen == -1)
{ {
// wx extension: we'll let %hs mean non-Unicode strings // wx extension: we'll let %hs mean non-Unicode strings
@ -466,18 +452,6 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
// %ls == %s == Unicode string // %ls == %s == Unicode string
m_type = wxPAT_PWCHAR; 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; done = true;
break; break;

View file

@ -32,13 +32,6 @@ class wxSymbolListCtrl;
class wxStdDialogButtonSizer; class wxStdDialogButtonSizer;
////@end forward declarations ////@end forward declarations
// __UNICODE__ is a symbol used by DialogBlocks-generated code.
#ifndef __UNICODE__
#if wxUSE_UNICODE
#define __UNICODE__
#endif
#endif
/*! /*!
* Symbols * Symbols
*/ */
@ -110,19 +103,15 @@ public:
/// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FONT /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FONT
void OnFontCtrlSelected( wxCommandEvent& event ); void OnFontCtrlSelected( wxCommandEvent& event );
#if defined(__UNICODE__)
/// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_SUBSET /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_SUBSET
void OnSubsetSelected( wxCommandEvent& event ); void OnSubsetSelected( wxCommandEvent& event );
/// wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET /// wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET
void OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& event ); void OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& event );
#endif
#if defined(__UNICODE__)
/// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FROM /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FROM
void OnFromUnicodeSelected( wxCommandEvent& event ); void OnFromUnicodeSelected( wxCommandEvent& event );
#endif
/// wxEVT_UPDATE_UI event handler for wxID_OK /// wxEVT_UPDATE_UI event handler for wxID_OK
void OnOkUpdate( wxUpdateUIEvent& event ); void OnOkUpdate( wxUpdateUIEvent& event );
@ -157,15 +146,11 @@ public:
////@begin wxSymbolPickerDialog member variables ////@begin wxSymbolPickerDialog member variables
wxComboBox* m_fontCtrl; wxComboBox* m_fontCtrl;
#if defined(__UNICODE__)
wxComboBox* m_subsetCtrl; wxComboBox* m_subsetCtrl;
#endif
wxSymbolListCtrl* m_symbolsCtrl; wxSymbolListCtrl* m_symbolsCtrl;
wxStaticText* m_symbolStaticCtrl; wxStaticText* m_symbolStaticCtrl;
wxTextCtrl* m_characterCodeCtrl; wxTextCtrl* m_characterCodeCtrl;
#if defined(__UNICODE__)
wxComboBox* m_fromUnicodeCtrl; wxComboBox* m_fromUnicodeCtrl;
#endif
wxStdDialogButtonSizer* m_stdButtonSizer; wxStdDialogButtonSizer* m_stdButtonSizer;
wxString m_fontName; wxString m_fontName;
bool m_fromUnicode; bool m_fromUnicode;

View file

@ -89,10 +89,8 @@ private:
// arbitrary 8 bit data // arbitrary 8 bit data
wxMBConv& m_conv; wxMBConv& m_conv;
#if wxUSE_UNICODE
// unconverted data from the last call to OnSysWrite() // unconverted data from the last call to OnSysWrite()
wxMemoryBuffer m_unconv; wxMemoryBuffer m_unconv;
#endif // wxUSE_UNICODE
wxDECLARE_NO_COPY_CLASS(wxStringOutputStream); wxDECLARE_NO_COPY_CLASS(wxStringOutputStream);
}; };

View file

@ -16,8 +16,6 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Utility functions used within wxSTC // Utility functions used within wxSTC
#if wxUSE_UNICODE
extern wxString stc2wx(const char* str); extern wxString stc2wx(const char* str);
extern wxString stc2wx(const char* str, size_t len); extern wxString stc2wx(const char* str, size_t len);
extern wxCharBuffer wx2stc(const wxString& str); extern wxCharBuffer wx2stc(const wxString& str);
@ -31,24 +29,4 @@ inline size_t wx2stclen(const wxString& WXUNUSED(str), const wxCharBuffer& buf)
return buf.length(); 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_ #endif // _WX_STC_PRIVATE_H_

View file

@ -107,18 +107,11 @@ public:
wxCharBuffer wxCharBuffer
cWC2MB(const wchar_t *in, size_t inLen, size_t *outLen) const; cWC2MB(const wchar_t *in, size_t inLen, size_t *outLen) const;
// convenience functions for converting MB or WC to/from wxWin default // Obsolete convenience functions.
#if wxUSE_UNICODE
wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); }
wxCharBuffer cWX2MB(const wchar_t *psz) const { return cWC2MB(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* cWC2WX(const wchar_t *psz) const { return psz; }
const wchar_t* cWX2WC(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 // return the maximum number of bytes that can be required to encode a
// single character in this encoding, e.g. 4 for UTF-8 // 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 // filenames are multibyte on Unix and widechar on Windows
#if wxMBFILES && wxUSE_UNICODE #if wxMBFILES
#define wxFNCONV(name) wxConvFileName->cWX2MB(name) #define wxFNCONV(name) wxConvFileName->cWX2MB(name)
#define wxFNSTRINGCAST wxMBSTRINGCAST #define wxFNSTRINGCAST wxMBSTRINGCAST
#else #else
@ -693,31 +686,23 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
// macros for the most common conversions // macros for the most common conversions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE #define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s)
#define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) #define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s)
#define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s)
// these functions should be used when the conversions really, really have // these functions should be used when the conversions really, really have
// to succeed (usually because we pass their results to a standard C // 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 // function which would crash if we passed nullptr to it), so these functions
// always return a valid pointer if their argument is non-null // always return a valid pointer if their argument is non-null
inline wxWCharBuffer wxSafeConvertMB2WX(const char *s) inline wxWCharBuffer wxSafeConvertMB2WX(const char *s)
{ {
return wxConvWhateverWorks.cMB2WC(s); return wxConvWhateverWorks.cMB2WC(s);
} }
inline wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) inline wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
{ {
return wxConvWhateverWorks.cWC2MB(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
// Macro that indicates the default encoding for converting C strings // Macro that indicates the default encoding for converting C strings
// to wxString. It provides a default value for a const wxMBConv& // to wxString. It provides a default value for a const wxMBConv&

View file

@ -352,9 +352,8 @@ private:
const wxMBConv& conv); const wxMBConv& conv);
#endif #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: // returns C string encoded as the implementation expects:
#if wxUSE_UNICODE
static const wchar_t* ImplStr(const wchar_t* str) static const wchar_t* ImplStr(const wchar_t* str)
{ return str ? str : wxT(""); } { return str ? str : wxT(""); }
static const SubstrBufFromWC ImplStr(const wchar_t* str, size_t n) 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, static SubstrBufFromMB ImplStr(const char* str, size_t n,
const wxMBConv& conv wxSTRING_DEFAULT_CONV_ARG) const wxMBConv& conv wxSTRING_DEFAULT_CONV_ARG)
{ return ConvertStr(str, n, conv); } { 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 // translates position index in wxString to/from index in underlying
// wxStringImpl: // wxStringImpl:
@ -1246,13 +1231,8 @@ public:
#endif #endif
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
#if !wxUSE_UNICODE // ANSI build wxString(const std::string& str)
// FIXME-UTF8: do this in UTF8 build #if wxUSE_UTF8_LOCALE_ONLY, too { assign(str.c_str(), str.length()); }
wxString(const std::string& str) : m_impl(str) {}
#else // Unicode
wxString(const std::string& str)
{ assign(str.c_str(), str.length()); }
#endif
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING #endif // wxNO_IMPLICIT_WXSTRING_ENCODING
#endif // wxUSE_STD_STRING #endif // wxUSE_STD_STRING
@ -1280,7 +1260,7 @@ public:
} }
#endif #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 // wxStringImpl is std::string in the encoding we want
#define wxStringToStdStringRetType const std::string& #define wxStringToStdStringRetType const std::string&
const std::string& ToStdString() const { return m_impl; } const std::string& ToStdString() const { return m_impl; }
@ -1597,16 +1577,8 @@ public:
template <typename T> template <typename T>
wxCharTypeBuffer<T> tchar_str(size_t *len = nullptr) const wxCharTypeBuffer<T> tchar_str(size_t *len = nullptr) const
{ {
#if wxUSE_UNICODE
// we need a helper dispatcher depending on type // we need a helper dispatcher depending on type
return wxPrivate::wxStringAsBufHelper<T>::Get(*this, len); return wxPrivate::wxStringAsBufHelper<T>::Get(*this, len);
#else // ANSI
// T can only be char in ANSI build
if ( len )
*len = length();
return wxCharTypeBuffer<T>::CreateNonOwned(wx_str(), length());
#endif // Unicode build kind
} }
// conversion to/from plain (i.e. 7 bit) ASCII: this is useful for // 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 // the behaviour of these functions with the strings containing anything
// else than 7 bit ASCII characters is undefined, use at your own risk. // 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, size_t len);
static wxString FromAscii(const char *ascii); static wxString FromAscii(const char *ascii);
static wxString FromAscii(char ascii); static wxString FromAscii(char ascii);
const wxScopedCharBuffer ToAscii(char replaceWith = '_') const; 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 // also provide unsigned char overloads as signed/unsigned doesn't matter
// for 7 bit ASCII characters // for 7 bit ASCII characters
@ -1764,7 +1728,6 @@ public:
const wxScopedCharBuffer ToUTF8() const { return utf8_str(); } const wxScopedCharBuffer ToUTF8() const { return utf8_str(); }
// functions for storing binary data in wxString: // functions for storing binary data in wxString:
#if wxUSE_UNICODE
static wxString From8BitData(const char *data, size_t len) static wxString From8BitData(const char *data, size_t len)
{ return wxString(data, wxConvISO8859_1, len); } { return wxString(data, wxConvISO8859_1, len); }
// version for NUL-terminated data: // version for NUL-terminated data:
@ -1772,15 +1735,6 @@ public:
{ return wxString(data, wxConvISO8859_1); } { return wxString(data, wxConvISO8859_1); }
const wxScopedCharBuffer To8BitData() const const wxScopedCharBuffer To8BitData() const
{ return mb_str(wxConvISO8859_1); } { 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 // conversions with (possible) format conversions: have to return a
// buffer with temporary data // buffer with temporary data
@ -1792,8 +1746,6 @@ public:
// type differs because a function may either return pointer to the buffer // type differs because a function may either return pointer to the buffer
// directly or have to use intermediate buffer for translation. // directly or have to use intermediate buffer for translation.
#if wxUSE_UNICODE
// this is an optimization: even though using mb_str(wxConvLibc) does the // this is an optimization: even though using mb_str(wxConvLibc) does the
// same thing (i.e. returns pointer to internal representation as locale is // 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 // 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 const wxScopedWCharBuffer wc_str() const
{ return AsWCharBuf(wxMBConvStrictUTF8()); } { return AsWCharBuf(wxMBConvStrictUTF8()); }
#endif #endif
// for compatibility with !wxUSE_UNICODE version // for compatibility only
const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const
{ return wc_str(); } { return wc_str(); }
@ -1830,23 +1782,6 @@ public:
const wxWX2WCbuf fn_str() const { return wc_str(); } const wxWX2WCbuf fn_str() const { return wc_str(); }
#endif // wxMBFILES/!wxMBFILES #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 #if wxUSE_UNICODE_UTF8
const wxScopedWCharBuffer t_str() const { return wc_str(); } const wxScopedWCharBuffer t_str() const { return wc_str(); }
#elif wxUSE_UNICODE_WCHAR #elif wxUSE_UNICODE_WCHAR
@ -3253,11 +3188,7 @@ public:
// as strpbrk() but starts at nStart, returns npos if not found // as strpbrk() but starts at nStart, returns npos if not found
size_t find_first_of(const wxString& str, size_t nStart = 0) const 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); } { return find_first_of(str.wc_str(), nStart); }
#else
{ return find_first_of(str.mb_str(), nStart); }
#endif
// same as above // same as above
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
size_t find_first_of(const char* sz, size_t nStart = 0) const; size_t find_first_of(const char* sz, size_t nStart = 0) const;
@ -3272,11 +3203,7 @@ public:
{ return find(c, nStart); } { return find(c, nStart); }
// find the last (starting from nStart) char from str in this string // 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 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); } { return find_last_of(str.wc_str(), nStart); }
#else
{ return find_last_of(str.mb_str(), nStart); }
#endif
// same as above // same as above
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
size_t find_last_of (const char* sz, size_t nStart = npos) const; 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 // as strspn() (starting from nStart), returns npos on failure
size_t find_first_not_of(const wxString& str, size_t nStart = 0) const 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); } { return find_first_not_of(str.wc_str(), nStart); }
#else
{ return find_first_not_of(str.mb_str(), nStart); }
#endif
// same as above // same as above
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
size_t find_first_not_of(const char* sz, size_t nStart = 0) const; 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; size_t find_first_not_of(wxUniChar ch, size_t nStart = 0) const;
// as strcspn() // as strcspn()
size_t find_last_not_of(const wxString& str, size_t nStart = npos) const 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); } { return find_last_not_of(str.wc_str(), nStart); }
#else
{ return find_last_not_of(str.mb_str(), nStart); }
#endif
// same as above // same as above
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
size_t find_last_not_of(const char* sz, size_t nStart = npos) const; 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 // common mb_str() and wxCStrData::AsChar() helper: performs the conversion
// and returns either m_convertedToChar.m_str (in which case its m_len is // and returns either m_convertedToChar.m_str (in which case its m_len is
// also updated) or nullptr if it failed // also updated) or nullptr if it failed
@ -3635,7 +3553,6 @@ private:
} }
ConvertedBuffer<char> m_convertedToChar; ConvertedBuffer<char> m_convertedToChar;
#endif // !wxUSE_UNICODE
#if !wxUSE_UNICODE_WCHAR #if !wxUSE_UNICODE_WCHAR
// common wc_str() and wxCStrData::AsWChar() helper for both UTF-8 and ANSI // 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 #endif // wxNO_IMPLICIT_WXSTRING_ENCODING
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&); 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 wxString&);
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&); WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&);
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxScopedWCharBuffer&); WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxScopedWCharBuffer&);
#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) #endif // defined(HAVE_WOSTREAM)
#endif // wxUSE_STD_IOSTREAM #endif // wxUSE_STD_IOSTREAM
@ -4259,39 +4176,19 @@ inline const wchar_t* wxCStrData::AsWChar() const
m_str->AsWChar(wxConvLibc); m_str->AsWChar(wxConvLibc);
#endif #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; return p + m_offset;
} }
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
inline const char* wxCStrData::AsChar() const 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); const char * const p = m_str->AsChar(wxConvLibc);
if ( !p ) if ( !p )
return ""; return "";
#else // !wxUSE_UNICODE || wxUSE_UTF8_LOCALE_ONLY #else // wxUSE_UTF8_LOCALE_ONLY
const char * const p = m_str->mb_str(); const char * const p = m_str->mb_str();
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #endif
return p + m_offset; return p + m_offset;
} }

View file

@ -22,8 +22,7 @@
// one for UTF-8 encoded char* string and one for "raw" wchar_t* strings (or // one for UTF-8 encoded char* string and one for "raw" wchar_t* strings (or
// char* in ANSI build). // char* in ANSI build).
// FIXME-UTF8: only wchar after we remove ANSI build #if wxUSE_UNICODE_WCHAR
#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE
struct WXDLLIMPEXP_BASE wxStringOperationsWchar struct WXDLLIMPEXP_BASE wxStringOperationsWchar
{ {
// moves the iterator to the next Unicode character // moves the iterator to the next Unicode character
@ -80,7 +79,7 @@ struct WXDLLIMPEXP_BASE wxStringOperationsWchar
static wxUniChar DecodeChar(const wxStringImpl::const_iterator& i) static wxUniChar DecodeChar(const wxStringImpl::const_iterator& i)
{ return *i; } { return *i; }
}; };
#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE #endif // wxUSE_UNICODE_WCHAR
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8

View file

@ -214,7 +214,7 @@ private:
wxScopedCharBuffer m_convertedChar; wxScopedCharBuffer m_convertedChar;
#endif // !wxUSE_UNICODE_WCHAR && !defined wx_NO_IMPLICIT_WXSTRING_ENCODING #endif // !wxUSE_UNICODE_WCHAR && !defined wx_NO_IMPLICIT_WXSTRING_ENCODING
#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
public: public:
operator const wchar_t*() const operator const wchar_t*() const
{ return const_cast<wxFormatString*>(this)->AsWChar(); } { return const_cast<wxFormatString*>(this)->AsWChar(); }
@ -222,7 +222,7 @@ private:
const wchar_t* InputAsWChar(); const wchar_t* InputAsWChar();
const wchar_t* AsWChar(); const wchar_t* AsWChar();
wxScopedWCharBuffer m_convertedWChar; wxScopedWCharBuffer m_convertedWChar;
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #endif // !wxUSE_UTF8_LOCALE_ONLY
private: private:
wxScopedCharBuffer m_char; 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) wxFORMAT_STRING_SPECIFIER(wchar_t, wxFormatString::Arg_Char | wxFormatString::Arg_Int)
#endif #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 #ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String) wxFORMAT_STRING_SPECIFIER(char*, wxFormatString::Arg_String)
wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String) wxFORMAT_STRING_SPECIFIER(unsigned char*, wxFormatString::Arg_String)
@ -849,12 +843,11 @@ struct wxArgNormalizer<const wxUniChar&> : public wxArgNormalizer<wchar_t>
// for wchar_t, default handler does the right thing // 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 // 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 // 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 // advantage of the fact that both char and wchar_t are converted into int
// in variadic arguments here. // in variadic arguments here.
#if wxUSE_UNICODE
template<typename T> template<typename T>
struct wxArgNormalizerNarrowChar struct wxArgNormalizerNarrowChar
{ {
@ -903,8 +896,6 @@ struct wxArgNormalizer<signed char>
: wxArgNormalizerNarrowChar<signed char>(value, fmt, index) {} : wxArgNormalizerNarrowChar<signed char>(value, fmt, index) {}
}; };
#endif // wxUSE_UNICODE
// convert references: // convert references:
WX_ARG_NORMALIZER_FORWARD(wxUniChar, const wxUniChar&); WX_ARG_NORMALIZER_FORWARD(wxUniChar, const wxUniChar&);
WX_ARG_NORMALIZER_FORWARD(const wxUniCharRef&, const wxUniChar&); WX_ARG_NORMALIZER_FORWARD(const wxUniCharRef&, const wxUniChar&);

View file

@ -86,9 +86,7 @@ class WXDLLIMPEXP_BASE wxMsgCatalog
public: public:
// Ctor is protected, because CreateFromXXX functions must be used, // Ctor is protected, because CreateFromXXX functions must be used,
// but destruction should be unrestricted // but destruction should be unrestricted
#if !wxUSE_UNICODE ~wxMsgCatalog() = default;
~wxMsgCatalog();
#endif
// load the catalog from disk or from data; caller is responsible for // load the catalog from disk or from data; caller is responsible for
// deleting them if not null // deleting them if not null
@ -107,9 +105,6 @@ public:
protected: protected:
wxMsgCatalog(const wxString& domain) wxMsgCatalog(const wxString& domain)
: m_pNext(nullptr), m_domain(domain) : m_pNext(nullptr), m_domain(domain)
#if !wxUSE_UNICODE
, m_conv(nullptr)
#endif
{} {}
private: private:
@ -120,12 +115,6 @@ private:
wxStringToStringHashMap m_messages; // all messages in the catalog wxStringToStringHashMap m_messages; // all messages in the catalog
wxString m_domain; // name of the domain 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; wxPluralFormsCalculatorPtr m_pluralFormsCalculator;
}; };
@ -166,11 +155,6 @@ public:
// wxTranslationsLoader // wxTranslationsLoader
bool AddCatalog(const wxString& domain, bool AddCatalog(const wxString& domain,
wxLanguage msgIdLanguage = wxLANGUAGE_ENGLISH_US); 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 // check if the given catalog is loaded
bool IsLoaded(const wxString& domain) const; bool IsLoaded(const wxString& domain) const;

View file

@ -36,13 +36,9 @@ WXDLLIMPEXP_BASE wxTextOutputStream &endl( wxTextOutputStream &stream );
class WXDLLIMPEXP_BASE wxTextInputStream class WXDLLIMPEXP_BASE wxTextInputStream
{ {
public: public:
#if wxUSE_UNICODE
wxTextInputStream(wxInputStream& s, wxTextInputStream(wxInputStream& s,
const wxString &sep=wxT(" \t"), const wxString &sep=wxT(" \t"),
const wxMBConv& conv = wxConvAuto()); const wxMBConv& conv = wxConvAuto());
#else
wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t"));
#endif
~wxTextInputStream(); ~wxTextInputStream();
const wxInputStream& GetInputStream() const { return m_input; } const wxInputStream& GetInputStream() const { return m_input; }
@ -67,9 +63,9 @@ public:
// Operators // Operators
wxTextInputStream& operator>>(wxString& word); wxTextInputStream& operator>>(wxString& word);
wxTextInputStream& operator>>(char& c); wxTextInputStream& operator>>(char& c);
#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE #if wxWCHAR_T_IS_REAL_TYPE
wxTextInputStream& operator>>(wchar_t& wc); wxTextInputStream& operator>>(wchar_t& wc);
#endif // wxUSE_UNICODE #endif
wxTextInputStream& operator>>(wxInt16& i); wxTextInputStream& operator>>(wxInt16& i);
wxTextInputStream& operator>>(wxInt32& i); wxTextInputStream& operator>>(wxInt32& i);
wxTextInputStream& operator>>(wxInt64& i); wxTextInputStream& operator>>(wxInt64& i);
@ -101,7 +97,6 @@ protected:
size_t m_validBegin, size_t m_validBegin,
m_validEnd; m_validEnd;
#if wxUSE_UNICODE
wxMBConv *m_conv; wxMBConv *m_conv;
// The second half of a surrogate character when using UTF-16 for wchar_t: // The second half of a surrogate character when using UTF-16 for wchar_t:
@ -112,7 +107,6 @@ protected:
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
wchar_t m_lastWChar; wchar_t m_lastWChar;
#endif // SIZEOF_WCHAR_T == 2 #endif // SIZEOF_WCHAR_T == 2
#endif // wxUSE_UNICODE
bool EatEOL(const wxChar &c); bool EatEOL(const wxChar &c);
void UngetLast(); // should be used instead of wxInputStream::Ungetch() because of Unicode issues void UngetLast(); // should be used instead of wxInputStream::Ungetch() because of Unicode issues
@ -132,13 +126,9 @@ enum wxEOL
class WXDLLIMPEXP_BASE wxTextOutputStream class WXDLLIMPEXP_BASE wxTextOutputStream
{ {
public: public:
#if wxUSE_UNICODE
wxTextOutputStream(wxOutputStream& s, wxTextOutputStream(wxOutputStream& s,
wxEOL mode = wxEOL_NATIVE, wxEOL mode = wxEOL_NATIVE,
const wxMBConv& conv = wxConvAuto()); const wxMBConv& conv = wxConvAuto());
#else
wxTextOutputStream(wxOutputStream& s, wxEOL mode = wxEOL_NATIVE);
#endif
virtual ~wxTextOutputStream(); virtual ~wxTextOutputStream();
const wxOutputStream& GetOutputStream() const { return m_output; } const wxOutputStream& GetOutputStream() const { return m_output; }
@ -168,9 +158,9 @@ public:
wxTextOutputStream& operator<<(const wxString& string); wxTextOutputStream& operator<<(const wxString& string);
wxTextOutputStream& operator<<(char c); wxTextOutputStream& operator<<(char c);
#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE #if wxWCHAR_T_IS_REAL_TYPE
wxTextOutputStream& operator<<(wchar_t wc); wxTextOutputStream& operator<<(wchar_t wc);
#endif // wxUSE_UNICODE #endif
wxTextOutputStream& operator<<(wxInt16 c); wxTextOutputStream& operator<<(wxInt16 c);
wxTextOutputStream& operator<<(wxInt32 c); wxTextOutputStream& operator<<(wxInt32 c);
wxTextOutputStream& operator<<(wxInt64 c); wxTextOutputStream& operator<<(wxInt64 c);
@ -186,7 +176,6 @@ protected:
wxOutputStream &m_output; wxOutputStream &m_output;
wxEOL m_mode; wxEOL m_mode;
#if wxUSE_UNICODE
wxMBConv *m_conv; wxMBConv *m_conv;
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
@ -194,7 +183,6 @@ protected:
// and couldn't be output when it was called the last time. // and couldn't be output when it was called the last time.
wchar_t m_lastWChar; wchar_t m_lastWChar;
#endif // SIZEOF_WCHAR_T == 2 #endif // SIZEOF_WCHAR_T == 2
#endif // wxUSE_UNICODE
wxDECLARE_NO_COPY_CLASS(wxTextOutputStream); wxDECLARE_NO_COPY_CLASS(wxTextOutputStream);
}; };

View file

@ -72,7 +72,6 @@ public:
// must be non-null) // must be non-null)
bool GetAsChar(char *c) const bool GetAsChar(char *c) const
{ {
#if wxUSE_UNICODE
if ( !IsAscii() ) if ( !IsAscii() )
{ {
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
@ -82,7 +81,6 @@ public:
return false; return false;
} }
#endif // wxUSE_UNICODE
*c = wx_truncate_cast(char, m_value); *c = wx_truncate_cast(char, m_value);
return true; return true;
@ -181,26 +179,18 @@ private:
// characters purely for performance reasons // characters purely for performance reasons
static value_type From8bit(char c) static value_type From8bit(char c)
{ {
#if wxUSE_UNICODE
if ( (unsigned char)c < 0x80 ) if ( (unsigned char)c < 0x80 )
return c; return c;
return FromHi8bit(c); return FromHi8bit(c);
#else
return c;
#endif
} }
static char To8bit(value_type c) static char To8bit(value_type c)
{ {
#if wxUSE_UNICODE
if ( c < 0x80 ) if ( c < 0x80 )
return wx_truncate_cast(char, c); return wx_truncate_cast(char, c);
return ToHi8bit(c); return ToHi8bit(c);
#else
return wx_truncate_cast(char, c);
#endif
} }
// helpers of the functions above called to deal with non-ASCII chars // helpers of the functions above called to deal with non-ASCII chars

View file

@ -389,12 +389,10 @@ WXDLLIMPEXP_BASE long wxExecute(const char* const* argv,
int flags = wxEXEC_ASYNC, int flags = wxEXEC_ASYNC,
wxProcess *process = nullptr, wxProcess *process = nullptr,
const wxExecuteEnv *env = nullptr); const wxExecuteEnv *env = nullptr);
#if wxUSE_UNICODE
WXDLLIMPEXP_BASE long wxExecute(const wchar_t* const* argv, WXDLLIMPEXP_BASE long wxExecute(const wchar_t* const* argv,
int flags = wxEXEC_ASYNC, int flags = wxEXEC_ASYNC,
wxProcess *process = nullptr, wxProcess *process = nullptr,
const wxExecuteEnv *env = nullptr); const wxExecuteEnv *env = nullptr);
#endif // wxUSE_UNICODE
// execute the command capturing its output into an array line by line, this is // execute the command capturing its output into an array line by line, this is
// always synchronous // always synchronous

View file

@ -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 wxMB2WC(wchar_t *buf, const char *psz, size_t n);
WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
#if wxUSE_UNICODE // Obsolete helpers.
#define wxMB2WX wxMB2WC #define wxMB2WX wxMB2WC
#define wxWX2MB wxWC2MB #define wxWX2MB wxWC2MB
#define wxWC2WX wxStrncpy #define wxWC2WX wxStrncpy
#define wxWX2WC wxStrncpy #define wxWX2WC wxStrncpy
#else
#define wxMB2WX wxStrncpy
#define wxWX2MB wxStrncpy
#define wxWC2WX wxWC2MB
#define wxWX2WC wxMB2WC
#endif
// RN: We could do the usual tricky compiler detection here, // 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 <string.h> #include <string.h>
#if wxUSE_UNICODE //implement our own wmem variants
//implement our own wmem variants inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l) {
{ for(;l && *s != c;--l, ++s) {}
for(;l && *s != c;--l, ++s) {}
if(l) if(l)
return const_cast<wxChar*>(s); return const_cast<wxChar*>(s);
return nullptr; return nullptr;
} }
inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len) inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
{ {
for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {} for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
if(len) if(len)
return *sz1 < *sz2 ? -1 : *sz1 > *sz2; return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
else else
return 0; return 0;
} }
inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len) inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
{ {
return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar)); return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
} }
inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len) inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
{ {
return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar)); return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
} }
inline wxChar* wxTmemset(wxChar* szOut, wxChar cIn, size_t len) inline wxChar* wxTmemset(wxChar* szOut, wxChar cIn, size_t len)
{ {
wxChar* szRet = szOut; wxChar* szRet = szOut;
while (len--) while (len--)
*szOut++ = cIn; *szOut++ = cIn;
return szRet; return szRet;
} }
#endif /* wxUSE_UNICODE */
// provide trivial wrappers for char* versions for both ANSI and Unicode builds // provide trivial wrappers for char* versions for both ANSI and Unicode builds
// (notice that these intentionally return "char *" and not "void *" unlike the // (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<typename T> template<typename T>
inline int wxStrcoll_String(const wxString& s1, const T& s2) 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 // 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 // wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is
// there just as optimization to avoid going through // there just as optimization to avoid going through
// wxStrcoll<wxScopedWCharBuffer>: // wxStrcoll<wxScopedWCharBuffer>:
return wxStrcoll((const wchar_t*)s1.wc_str(), s2); return wxStrcoll((const wchar_t*)s1.wc_str(), s2);
#else
return wxStrcoll((const char*)s1.mb_str(), s2);
#endif
} }
#endif // defined(wxCRT_Strcoll[AW]) #endif // defined(wxCRT_Strcoll[AW])

View file

@ -270,18 +270,11 @@ WXDLLIMPEXP_BASE int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t
} }
#endif #endif
/* FIXME-UTF8: remove this once we are Unicode only */ /* FIXME-UTF8: remove this */
#if wxUSE_UNICODE #define wxCRT_StrlenNative wxCRT_StrlenW
#define wxCRT_StrlenNative wxCRT_StrlenW #define wxCRT_StrncmpNative wxCRT_StrncmpW
#define wxCRT_StrncmpNative wxCRT_StrncmpW #define wxCRT_ToupperNative wxCRT_ToupperW
#define wxCRT_ToupperNative wxCRT_ToupperW #define wxCRT_TolowerNative wxCRT_TolowerW
#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
#ifndef wxCRT_StrcatW #ifndef wxCRT_StrcatW
WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcatW(wchar_t *dest, const wchar_t *src); 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* /* 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: */ 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_Fopen fopen
#define wxCRT_Freopen freopen #define wxCRT_Freopen freopen

View file

@ -146,9 +146,7 @@
// for wxString code, define wxUSE_WXVSNPRINTF to indicate that wx // for wxString code, define wxUSE_WXVSNPRINTF to indicate that wx
// implementation is used no matter what (in UTF-8 build, either *A or *W // implementation is used no matter what (in UTF-8 build, either *A or *W
// version may be called): // version may be called):
#if !wxUSE_UNICODE #if wxUSE_UNICODE_WCHAR
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA
#elif wxUSE_UNICODE_WCHAR
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFW #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFW
#elif wxUSE_UTF8_LOCALE_ONLY #elif wxUSE_UTF8_LOCALE_ONLY
#define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA #define wxUSE_WXVSNPRINTF wxUSE_WXVSNPRINTFA
@ -238,15 +236,9 @@
// user-friendly wrappers to CRT functions // user-friendly wrappers to CRT functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// FIXME-UTF8: remove this // FIXME-UTF8: remove this
#if wxUSE_UNICODE #define wxCRT_PrintfNative wxCRT_PrintfW
#define wxCRT_PrintfNative wxCRT_PrintfW #define wxCRT_FprintfNative wxCRT_FprintfW
#define wxCRT_FprintfNative wxCRT_FprintfW
#else
#define wxCRT_PrintfNative wxCRT_PrintfA
#define wxCRT_FprintfNative wxCRT_FprintfA
#endif
wxGCC_ONLY_WARNING_SUPPRESS(format-nonliteral) 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 int WXDLLIMPEXP_BASE
wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr); wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr);
#if wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
int WXDLLIMPEXP_BASE wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...); int WXDLLIMPEXP_BASE wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...);
#endif #endif
@ -356,8 +346,6 @@ WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (wchar_t*, size_t, const wxFormatStrin
int WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE
wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr); wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
#endif // wxUSE_UNICODE
// We can't use wxArgNormalizer<T> for variadic arguments to wxScanf() etc. // We can't use wxArgNormalizer<T> for variadic arguments to wxScanf() etc.
// because they are writable, so instead of providing friendly template // because they are writable, so instead of providing friendly template
// vararg-like functions, we just provide both char* and wchar_t* variants // vararg-like functions, we just provide both char* and wchar_t* variants

View file

@ -71,12 +71,10 @@ public:
const wxSize& GetInitialSize() const { return m_initialSize; } const wxSize& GetInitialSize() const { return m_initialSize; }
bool GetShowIconic() const { return m_showIconic; } bool GetShowIconic() const { return m_showIconic; }
#if wxUSE_UNICODE
// Global context for Pango layout. Either use X11 // Global context for Pango layout. Either use X11
// or use Xft rendering according to GDK_USE_XFT // or use Xft rendering according to GDK_USE_XFT
// environment variable // environment variable
PangoContext* GetPangoContext(); PangoContext* GetPangoContext();
#endif
wxXVisualInfo* GetVisualInfo(WXDisplay* WXUNUSED(display)) wxXVisualInfo* GetVisualInfo(WXDisplay* WXUNUSED(display))
{ {

View file

@ -134,10 +134,8 @@ protected:
wxRegion m_currentClippingRegion; wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion; wxRegion m_paintClippingRegion;
#if wxUSE_UNICODE
PangoContext *m_context; PangoContext *m_context;
PangoFontDescription *m_fontdesc; PangoFontDescription *m_fontdesc;
#endif
void SetUpDC(); void SetUpDC();
void Destroy(); void Destroy();

View file

@ -39,13 +39,8 @@ class WXDLLIMPEXP_FWD_CORE wxWindow;
// Some Unicode <-> UTF8 macros stolen from GTK // Some Unicode <-> UTF8 macros stolen from GTK
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE #define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s)
#define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s) #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s)
#define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s)
#else
#define wxGTK_CONV(s) s.c_str()
#define wxGTK_CONV_BACK(s) s
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// we maintain a hash table which contains the mapping from Widget to wxWindow // we maintain a hash table which contains the mapping from Widget to wxWindow

View file

@ -48,10 +48,7 @@
#include <locale.h> #include <locale.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <wctype.h>
#if wxUSE_UNICODE
#include <wctype.h>
#endif
// Locale type and identifier name // Locale type and identifier name
typedef locale_t wxXLocale_t; 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) inline unsigned long wxStrtoul_lA(const char *c, char **endptr, int base, const wxXLocale& loc)
{ return wxCRT_Strtoul_lA(c, endptr, base, loc.Get()); } { 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 inline int wxIsalnum_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Isalnum_lW wxXLOCALE_IDENT(iswalnum_l) { return wxCRT_Isalnum_lW(c, loc.Get()); }
#define wxCRT_Isalpha_lW wxXLOCALE_IDENT(iswalpha_l) inline int wxIsalpha_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Iscntrl_lW wxXLOCALE_IDENT(iswcntrl_l) { return wxCRT_Isalpha_lW(c, loc.Get()); }
#define wxCRT_Isdigit_lW wxXLOCALE_IDENT(iswdigit_l) inline int wxIscntrl_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Isgraph_lW wxXLOCALE_IDENT(iswgraph_l) { return wxCRT_Iscntrl_lW(c, loc.Get()); }
#define wxCRT_Islower_lW wxXLOCALE_IDENT(iswlower_l) inline int wxIsdigit_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Isprint_lW wxXLOCALE_IDENT(iswprint_l) { return wxCRT_Isdigit_lW(c, loc.Get()); }
#define wxCRT_Ispunct_lW wxXLOCALE_IDENT(iswpunct_l) inline int wxIsgraph_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Isspace_lW wxXLOCALE_IDENT(iswspace_l) { return wxCRT_Isgraph_lW(c, loc.Get()); }
#define wxCRT_Isupper_lW wxXLOCALE_IDENT(iswupper_l) inline int wxIslower_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Isxdigit_lW wxXLOCALE_IDENT(iswxdigit_l) { return wxCRT_Islower_lW(c, loc.Get()); }
#define wxCRT_Tolower_lW wxXLOCALE_IDENT(towlower_l) inline int wxIsprint_l(wchar_t c, const wxXLocale& loc)
#define wxCRT_Toupper_lW wxXLOCALE_IDENT(towupper_l) { return wxCRT_Isprint_lW(c, loc.Get()); }
inline int wxIspunct_l(wchar_t c, const wxXLocale& loc)
inline int wxIsalnum_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Ispunct_lW(c, loc.Get()); }
{ return wxCRT_Isalnum_lW(c, loc.Get()); } inline int wxIsspace_l(wchar_t c, const wxXLocale& loc)
inline int wxIsalpha_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Isspace_lW(c, loc.Get()); }
{ return wxCRT_Isalpha_lW(c, loc.Get()); } inline int wxIsupper_l(wchar_t c, const wxXLocale& loc)
inline int wxIscntrl_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Isupper_lW(c, loc.Get()); }
{ return wxCRT_Iscntrl_lW(c, loc.Get()); } inline int wxIsxdigit_l(wchar_t c, const wxXLocale& loc)
inline int wxIsdigit_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Isxdigit_lW(c, loc.Get()); }
{ return wxCRT_Isdigit_lW(c, loc.Get()); } inline wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc)
inline int wxIsgraph_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Tolower_lW(c, loc.Get()); }
{ return wxCRT_Isgraph_lW(c, loc.Get()); } inline wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc)
inline int wxIslower_l(wchar_t c, const wxXLocale& loc) { return wxCRT_Toupper_lW(c, loc.Get()); }
{ 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 // stdlib functions for numeric <-> string conversion
// (see notes above about missing functions) // (see notes above about missing functions)
#define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l) #define wxCRT_Strtod_lW wxXLOCALE_IDENT(wcstod_l)
#define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l) #define wxCRT_Strtol_lW wxXLOCALE_IDENT(wcstol_l)
#define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l) #define wxCRT_Strtoul_lW wxXLOCALE_IDENT(wcstoul_l)
inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc) inline double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc)
{ return wxCRT_Strtod_lW(c, endptr, loc.Get()); } { return wxCRT_Strtod_lW(c, endptr, loc.Get()); }
inline long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc) 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()); } { 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) 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()); } { 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
#else // !wxHAS_XLOCALE_SUPPORT #else // !wxHAS_XLOCALE_SUPPORT
// ctype functions // ctype functions
int WXDLLIMPEXP_BASE wxIsalnum_l(const wxUniChar& c, const wxXLocale& loc); int WXDLLIMPEXP_BASE wxIsalnum_l(const wxUniChar& c, const wxXLocale& loc);

View file

@ -88,9 +88,6 @@ private:
// are irrelevant) and wxXML_ELEMENT_NODE (e.g. in <title>hi</title> there is // are irrelevant) and wxXML_ELEMENT_NODE (e.g. in <title>hi</title> there is
// element with name="title", irrelevant content and one child (wxXML_TEXT_NODE // element with name="title", irrelevant content and one child (wxXML_TEXT_NODE
// with content="hi"). // 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 class WXDLLIMPEXP_XML wxXmlNode
{ {
@ -280,22 +277,11 @@ public:
void SetFileType(wxTextFileType fileType); void SetFileType(wxTextFileType fileType);
void AppendToProlog(wxXmlNode *node); 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(); static wxVersionInfo GetLibraryVersionInfo();
private: private:
wxString m_version; wxString m_version;
wxString m_fileEncoding; wxString m_fileEncoding;
#if !wxUSE_UNICODE
wxString m_encoding;
#endif
wxXmlDoctype m_doctype; wxXmlDoctype m_doctype;
wxXmlNode *m_docNode; wxXmlNode *m_docNode;
wxTextFileType m_fileType; wxTextFileType m_fileType;

View file

@ -314,7 +314,7 @@ public:
{ {
Register(); Register();
} }
#if 0 // wxUSE_UNICODE #if 0
wxTypeInfo(wxTypeKind kind, wxTypeInfo(wxTypeKind kind,
wxVariant2StringFnc to, wxString2VariantFnc from, wxVariant2StringFnc to, wxString2VariantFnc from,
const char *name): const char *name):

View file

@ -823,10 +823,10 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel,
m_music_model = new MyMusicTreeModel; m_music_model = new MyMusicTreeModel;
m_ctrl[Page_Music]->AssociateModel( m_music_model.get() ); 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]->EnableDragSource( wxDF_UNICODETEXT );
m_ctrl[Page_Music]->EnableDropTarget( 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: // column 0 of the view control:
@ -1768,12 +1768,9 @@ void MyFrame::OnSorted( wxDataViewEvent &event )
void MyFrame::OnDataViewChar(wxKeyEvent& event) void MyFrame::OnDataViewChar(wxKeyEvent& event)
{ {
wxString key; wxString key;
#if wxUSE_UNICODE
if ( event.GetUnicodeKey() != WXK_NONE ) if ( event.GetUnicodeKey() != WXK_NONE )
key.Printf("\"%c\"", event.GetUnicodeKey()); key.Printf("\"%c\"", event.GetUnicodeKey());
else else if ( event.GetKeyCode() != WXK_NONE )
#endif
if ( event.GetKeyCode() != WXK_NONE )
key.Printf("wxKeyCode(%d)", event.GetKeyCode()); key.Printf("wxKeyCode(%d)", event.GetKeyCode());
else else
key = "unknown key"; key = "unknown key";

View file

@ -38,11 +38,9 @@ protected:
s += wxString(static_cast<const char *>(data), size); s += wxString(static_cast<const char *>(data), size);
break; break;
#if wxUSE_UNICODE
case wxIPC_UNICODETEXT: case wxIPC_UNICODETEXT:
s += wxString(static_cast<const wchar_t *>(data), size); s += wxString(static_cast<const wchar_t *>(data), size);
break; break;
#endif // wxUSE_UNICODE
case wxIPC_UTF8TEXT: case wxIPC_UTF8TEXT:
s += wxString::FromUTF8(static_cast<const char *>(data), size); s += wxString::FromUTF8(static_cast<const char *>(data), size);

View file

@ -531,11 +531,9 @@ wxString GetKeyName(const wxKeyEvent &event)
if ( keycode >= 32 && keycode < 128 ) if ( keycode >= 32 && keycode < 128 )
return wxString::Format("'%c'", (unsigned char)keycode); return wxString::Format("'%c'", (unsigned char)keycode);
#if wxUSE_UNICODE
int uc = event.GetUnicodeKey(); int uc = event.GetUnicodeKey();
if ( uc != WXK_NONE ) if ( uc != WXK_NONE )
return wxString::Format("'%c'", uc); return wxString::Format("'%c'", uc);
#endif
return "unknown"; return "unknown";
} }
@ -546,11 +544,7 @@ void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event)
wxString msg; wxString msg;
// event key_name KeyCode modifiers Unicode raw_code raw_flags pos // event key_name KeyCode modifiers Unicode raw_code raw_flags pos
msg.Printf("%7s %15s %5d %c%c%c%c" msg.Printf("%7s %15s %5d %c%c%c%c"
#if wxUSE_UNICODE
"%5d (U+%04x)" "%5d (U+%04x)"
#else
" none "
#endif
#ifdef wxHAS_RAW_KEY_CODES #ifdef wxHAS_RAW_KEY_CODES
" %7lu 0x%08lx" " %7lu 0x%08lx"
#else #else
@ -566,10 +560,8 @@ void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event)
event.AltDown() ? 'A' : '-', event.AltDown() ? 'A' : '-',
event.ShiftDown() ? 'S' : '-', event.ShiftDown() ? 'S' : '-',
event.MetaDown() ? 'M' : '-' event.MetaDown() ? 'M' : '-'
#if wxUSE_UNICODE
, event.GetUnicodeKey() , event.GetUnicodeKey()
, event.GetUnicodeKey() , event.GetUnicodeKey()
#endif
#ifdef wxHAS_RAW_KEY_CODES #ifdef wxHAS_RAW_KEY_CODES
, (unsigned long) event.GetRawKeyCode() , (unsigned long) event.GetRawKeyCode()
, (unsigned long) event.GetRawKeyFlags() , (unsigned long) event.GetRawKeyFlags()

View file

@ -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); 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 (日本語)"; const char *test = "Hebrew שלום -- Japanese (日本語)";
wxString tmp = wxConvUTF8.cMB2WC( test ); wxString tmp = wxConvUTF8.cMB2WC( test );
dc.DrawText( tmp, dc.FromDIP(10), dc.FromDIP(200) ); dc.DrawText( tmp, dc.FromDIP(10), dc.FromDIP(200) );
#endif
wxPoint points[5]; wxPoint points[5];
points[0].x = 0; points[0].x = 0;

View file

@ -2713,15 +2713,11 @@ void FormMain::OnAbout(wxCommandEvent& WXUNUSED(event))
wxString msg; wxString msg;
msg.Printf( "wxPropertyGrid Sample" msg.Printf( "wxPropertyGrid Sample"
#if wxUSE_UNICODE
#if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8 #if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8
" <utf-8>" " <utf-8>"
#else #else
" <unicode>" " <unicode>"
#endif #endif
#else
" <ansi>"
#endif
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
" <debug>" " <debug>"
#else #else

View file

@ -717,9 +717,7 @@ void MyTextCtrl::LogKeyEvent(const wxString& name, wxKeyEvent& event) const
} }
} }
#if wxUSE_UNICODE
key += wxString::Format(" (Unicode: %#04x)", event.GetUnicodeKey()); key += wxString::Format(" (Unicode: %#04x)", event.GetUnicodeKey());
#endif // wxUSE_UNICODE
wxLogMessage( "%s event: %s (flags = %c%c%c%c)", wxLogMessage( "%s event: %s (flags = %c%c%c%c)",
name, name,
@ -1184,11 +1182,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_horizontal->SetFont(wxFontInfo(18) m_horizontal->SetFont(wxFontInfo(18)
.Family(wxFONTFAMILY_SWISS) .Family(wxFONTFAMILY_SWISS)
.Encoding(wxFONTENCODING_CP1251)); .Encoding(wxFONTENCODING_CP1251));
#if wxUSE_UNICODE
m_horizontal->AppendText(L"\x0412\x0430\x0434\x0438\x043c \x0426"); 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 else

View file

@ -45,9 +45,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(MyApp, wxApp);
wxBEGIN_EVENT_TABLE(MyApp, wxApp) wxBEGIN_EVENT_TABLE(MyApp, wxApp)
EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo) EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo)
EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo) EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo)
#if wxUSE_UNICODE
EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo) EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo)
#endif // wxUSE_UNICODE
EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo) EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo)
EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2) EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2)
EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3) EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3)
@ -83,9 +81,7 @@ bool MyApp::OnInit()
wxMenu *test_menu = new wxMenu; wxMenu *test_menu = new wxMenu;
test_menu->Append(TYPES_VARIANT, "&Variant test"); test_menu->Append(TYPES_VARIANT, "&Variant test");
test_menu->Append(TYPES_BYTEORDER, "&Byteorder test"); test_menu->Append(TYPES_BYTEORDER, "&Byteorder test");
#if wxUSE_UNICODE
test_menu->Append(TYPES_UNICODE, "&Unicode test"); test_menu->Append(TYPES_UNICODE, "&Unicode test");
#endif // wxUSE_UNICODE
test_menu->Append(TYPES_STREAM, "&Stream test"); test_menu->Append(TYPES_STREAM, "&Stream test");
test_menu->Append(TYPES_STREAM2, "&Stream seek test"); test_menu->Append(TYPES_STREAM2, "&Stream seek test");
test_menu->Append(TYPES_STREAM3, "&Stream error test"); test_menu->Append(TYPES_STREAM3, "&Stream error test");
@ -870,7 +866,6 @@ void MyApp::DoStreamDemo7(wxCommandEvent& WXUNUSED(event))
textCtrl.WriteText( str ); textCtrl.WriteText( str );
} }
#if wxUSE_UNICODE
void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event)) void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event))
{ {
wxTextCtrl& textCtrl = * GetTextCtrl(); wxTextCtrl& textCtrl = * GetTextCtrl();
@ -889,7 +884,6 @@ void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event))
puts( str.mbc_str() ); puts( str.mbc_str() );
} }
#endif
void MyApp::DoMIMEDemo(wxCommandEvent& WXUNUSED(event)) void MyApp::DoMIMEDemo(wxCommandEvent& WXUNUSED(event))
{ {

View file

@ -29,9 +29,7 @@ public:
void DoStreamDemo5(wxCommandEvent& event); void DoStreamDemo5(wxCommandEvent& event);
void DoStreamDemo6(wxCommandEvent& event); void DoStreamDemo6(wxCommandEvent& event);
void DoStreamDemo7(wxCommandEvent& event); void DoStreamDemo7(wxCommandEvent& event);
#if wxUSE_UNICODE
void DoUnicodeDemo(wxCommandEvent& event); void DoUnicodeDemo(wxCommandEvent& event);
#endif // wxUSE_UNICODE
void DoMIMEDemo(wxCommandEvent& event); void DoMIMEDemo(wxCommandEvent& event);
wxTextCtrl* GetTextCtrl() const { return m_textCtrl; } wxTextCtrl* GetTextCtrl() const { return m_textCtrl; }

View file

@ -39,11 +39,7 @@ using namespace std;
struct wxObjectCodeReaderCallback::wxObjectCodeReaderCallbackInternal struct wxObjectCodeReaderCallback::wxObjectCodeReaderCallbackInternal
{ {
#if wxUSE_UNICODE
map<int,wstring> m_objectNames; map<int,wstring> m_objectNames;
#else
map<int,string> m_objectNames;
#endif
void SetObjectName(int objectID, const wxString &name ) void SetObjectName(int objectID, const wxString &name )
{ {

View file

@ -380,13 +380,7 @@ wxString wxAcceleratorEntry::AsPossiblyLocalizedString(bool localized) const
if ( n == WXSIZEOF(wxKeyNames) ) if ( n == WXSIZEOF(wxKeyNames) )
{ {
// must be a simple key // must be a simple key
if ( if ( wxIsprint(code) )
#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) )
{ {
text << (wxChar)code; text << (wxChar)code;
} }

View file

@ -142,12 +142,10 @@ wxAppConsoleBase::wxAppConsoleBase()
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
SetTraceMasks(); SetTraceMasks();
#if wxUSE_UNICODE // SetTraceMasks call can cause an apptraits to be
// In unicode mode the SetTraceMasks call can cause an apptraits to be
// created, but since we are still in the constructor the wrong kind will // 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. // be created for GUI apps. Destroy it so it can be created again later.
wxDELETE(m_traits); wxDELETE(m_traits);
#endif
#endif #endif
wxEvtHandler::AddFilter(this); wxEvtHandler::AddFilter(this);
@ -1173,12 +1171,10 @@ void wxOnAssert(const wxChar *file,
const wxChar *cond, const wxChar *cond,
const wxChar *msg) 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 // so it could be called directly from the user code and this might happen
// even when wxTheAssertHandler is null // even when wxTheAssertHandler is null
#if wxUSE_UNICODE
if ( wxTheAssertHandler ) if ( wxTheAssertHandler )
#endif // wxUSE_UNICODE
wxTheAssertHandler(file, line, func, cond, msg); wxTheAssertHandler(file, line, func, cond, msg);
} }
@ -1200,7 +1196,6 @@ void wxOnAssert(const char *file,
wxTheAssertHandler(file, line, func, cond, msg); wxTheAssertHandler(file, line, func, cond, msg);
} }
#if wxUSE_UNICODE
void wxOnAssert(const char *file, void wxOnAssert(const char *file,
int line, int line,
const char *func, const char *func,
@ -1226,7 +1221,6 @@ void wxOnAssert(const char *file,
{ {
wxTheAssertHandler(file, line, func, cond, msg); wxTheAssertHandler(file, line, func, cond, msg);
} }
#endif // wxUSE_UNICODE
#endif // wxDEBUG_LEVEL #endif // wxDEBUG_LEVEL

View file

@ -206,10 +206,8 @@ struct wxCmdLineParserData
// methods // methods
wxCmdLineParserData(); wxCmdLineParserData();
void SetArguments(int argc, char **argv); void SetArguments(int argc, char **argv);
#if wxUSE_UNICODE
void SetArguments(int argc, wxChar **argv); void SetArguments(int argc, wxChar **argv);
void SetArguments(int argc, const wxCmdLineArgsArray& argv); void SetArguments(int argc, const wxCmdLineArgsArray& argv);
#endif // wxUSE_UNICODE
void SetArguments(const wxString& cmdline); void SetArguments(const wxString& cmdline);
int FindOption(const wxString& name); 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) void wxCmdLineParserData::SetArguments(int argc, wxChar **argv)
{ {
m_arguments.clear(); m_arguments.clear();
@ -461,8 +457,6 @@ void wxCmdLineParserData::SetArguments(int WXUNUSED(argc),
m_arguments = argv.GetArguments(); m_arguments = argv.GetArguments();
} }
#endif // wxUSE_UNICODE
void wxCmdLineParserData::SetArguments(const wxString& cmdLine) void wxCmdLineParserData::SetArguments(const wxString& cmdLine)
{ {
m_arguments.clear(); m_arguments.clear();
@ -542,8 +536,6 @@ void wxCmdLineParser::SetCmdLine(int argc, char **argv)
m_data->SetArguments(argc, argv); m_data->SetArguments(argc, argv);
} }
#if wxUSE_UNICODE
void wxCmdLineParser::SetCmdLine(int argc, wxChar **argv) void wxCmdLineParser::SetCmdLine(int argc, wxChar **argv)
{ {
m_data->SetArguments(argc, argv); m_data->SetArguments(argc, argv);
@ -554,8 +546,6 @@ void wxCmdLineParser::SetCmdLine(int argc, const wxCmdLineArgsArray& argv)
m_data->SetArguments(argc, argv); m_data->SetArguments(argc, argv);
} }
#endif // wxUSE_UNICODE
void wxCmdLineParser::SetCmdLine(const wxString& cmdline) void wxCmdLineParser::SetCmdLine(const wxString& cmdline)
{ {
m_data->SetArguments(cmdline); m_data->SetArguments(cmdline);

View file

@ -1528,9 +1528,7 @@ wxDateTime::ParseFormat(const wxString& date,
else if else if
( (
*input == wxS('-') *input == wxS('-')
#if wxUSE_UNICODE
|| *input == wxString::FromUTF8("\xe2\x88\x92") || *input == wxString::FromUTF8("\xe2\x88\x92")
#endif
) )
minusFound = true; minusFound = true;
else else

View file

@ -43,9 +43,7 @@ union Float64Data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv) wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv)
#if wxUSE_UNICODE
: m_conv(conv.Clone()) : m_conv(conv.Clone())
#endif // wxUSE_UNICODE
{ {
// It is unused in non-Unicode build, so suppress a warning there. // It is unused in non-Unicode build, so suppress a warning there.
wxUnusedVar(conv); wxUnusedVar(conv);
@ -59,19 +57,15 @@ wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv)
#endif // wxUSE_APPLE_IEEE #endif // wxUSE_APPLE_IEEE
} }
#if wxUSE_UNICODE
void wxDataStreamBase::SetConv( const wxMBConv &conv ) void wxDataStreamBase::SetConv( const wxMBConv &conv )
{ {
delete m_conv; delete m_conv;
m_conv = conv.Clone(); m_conv = conv.Clone();
} }
#endif
wxDataStreamBase::~wxDataStreamBase() wxDataStreamBase::~wxDataStreamBase()
{ {
#if wxUSE_UNICODE
delete m_conv; delete m_conv;
#endif // wxUSE_UNICODE
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -179,18 +173,12 @@ wxString wxDataInputStream::ReadString()
const size_t len = Read32(); const size_t len = Read32();
if ( len > 0 ) if ( len > 0 )
{ {
#if wxUSE_UNICODE
wxCharBuffer tmp(len); wxCharBuffer tmp(len);
if ( tmp ) if ( tmp )
{ {
m_input->Read(tmp.data(), len); m_input->Read(tmp.data(), len);
ret = m_conv->cMB2WC(tmp.data(), len, nullptr); ret = m_conv->cMB2WC(tmp.data(), len, nullptr);
} }
#else
wxStringBuffer buf(ret, len);
if ( buf )
m_input->Read(buf, len);
#endif
} }
return ret; return ret;
@ -585,13 +573,8 @@ void wxDataOutputStream::Write8(wxUint8 i)
void wxDataOutputStream::WriteString(const wxString& string) void wxDataOutputStream::WriteString(const wxString& string)
{ {
#if wxUSE_UNICODE
const wxWX2MBbuf buf = string.mb_str(*m_conv); const wxWX2MBbuf buf = string.mb_str(*m_conv);
size_t len = buf.length(); size_t len = buf.length();
#else
const wxWX2MBbuf buf = string.mb_str();
size_t len = string.size();
#endif
Write32(len); Write32(len);
if (len > 0) if (len > 0)
m_output->Write(buf, len); m_output->Write(buf, len);

View file

@ -175,9 +175,7 @@ wxString wxDynamicLibrary::CanonicalizePluginName(const wxString& name,
{ {
suffix = wxPlatformInfo::Get().GetPortIdShortName(); suffix = wxPlatformInfo::Get().GetPortIdShortName();
} }
#if wxUSE_UNICODE
suffix << wxT('u'); suffix << wxT('u');
#endif
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
suffix << wxT('d'); suffix << wxT('d');
#endif #endif

View file

@ -768,9 +768,7 @@ wxPoint wxMouseEvent::GetLogicalPosition(const wxDC& dc) const
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxKeyEvent::wxKeyEvent(wxEventType type) wxKeyEvent::wxKeyEvent(wxEventType type)
#if wxUSE_UNICODE
: m_uniChar(WXK_NONE) : m_uniChar(WXK_NONE)
#endif
{ {
m_eventType = type; m_eventType = type;
m_keyCode = WXK_NONE; m_keyCode = WXK_NONE;

View file

@ -161,7 +161,6 @@ bool wxFFile::Write(const wxString& s, const wxMBConv& conv)
const wxWX2MBbuf buf = s.mb_str(conv); const wxWX2MBbuf buf = s.mb_str(conv);
#if wxUSE_UNICODE
const size_t size = buf.length(); const size_t size = buf.length();
if ( !size ) 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. // must fail too to indicate that we can't save the data.
return false; return false;
} }
#else
const size_t size = s.length();
#endif
return Write(buf, size) == size; return Write(buf, size) == size;
} }

View file

@ -365,7 +365,6 @@ bool wxFile::Write(const wxString& s, const wxMBConv& conv)
const wxWX2MBbuf buf = s.mb_str(conv); const wxWX2MBbuf buf = s.mb_str(conv);
#if wxUSE_UNICODE
const size_t size = buf.length(); const size_t size = buf.length();
if ( !size ) 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. // must fail too to indicate that we can't save the data.
return false; return false;
} }
#else
const size_t size = s.length();
#endif
return Write(buf, size) == size; return Write(buf, size) == size;
} }

View file

@ -424,17 +424,12 @@ wxFileConfig::wxFileConfig(wxInputStream &inStream, const wxMBConv& conv)
} }
while ( !inStream.Eof() ); while ( !inStream.Eof() );
#if wxUSE_UNICODE
size_t len; size_t len;
cbuf = conv.cMB2WC((char *)buf.GetData(), buf.GetDataLen() + 1, &len); cbuf = conv.cMB2WC((char *)buf.GetData(), buf.GetDataLen() + 1, &len);
if ( !len && buf.GetDataLen() ) if ( !len && buf.GetDataLen() )
{ {
wxLogError(_("Failed to read config options.")); 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 // parse the input contents if there is anything to parse
if ( cbuf ) if ( cbuf )
@ -2072,17 +2067,9 @@ static wxString FilterOutEntryName(const wxString& str)
for ( const wxChar *pc = str.c_str(); *pc != wxT('\0'); pc++ ) { for ( const wxChar *pc = str.c_str(); *pc != wxT('\0'); pc++ ) {
const wxChar c = *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 // NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR
// should *not* be quoted // should *not* be quoted
if ( if ( !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%()"), c) )
#if !wxUSE_UNICODE
((unsigned char)c < 127) &&
#endif // ANSI
!wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%()"), c) )
{ {
strResult += wxT('\\'); strResult += wxT('\\');
} }

View file

@ -734,9 +734,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
// for the compilers which have Unicode version of _getcwd(), call it // for the compilers which have Unicode version of _getcwd(), call it
// directly, for the others call the ANSI version and do the translation // directly, for the others call the ANSI version and do the translation
#if !wxUSE_UNICODE
#define cbuf buf
#else // wxUSE_UNICODE
bool needsANSI = true; bool needsANSI = true;
#if !defined(HAVE_WGETCWD) #if !defined(HAVE_WGETCWD)
@ -752,7 +749,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
#endif #endif
if ( needsANSI ) if ( needsANSI )
#endif // wxUSE_UNICODE
{ {
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
ok = _getcwd(cbuf, sz) != nullptr; ok = _getcwd(cbuf, sz) != nullptr;
@ -760,10 +756,8 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
ok = getcwd(cbuf, sz) != nullptr; ok = getcwd(cbuf, sz) != nullptr;
#endif // platform #endif // platform
#if wxUSE_UNICODE
// finally convert the result to Unicode if needed // finally convert the result to Unicode if needed
wxConvFile.MB2WC(buf, cbuf, sz); wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE
} }
if ( !ok ) if ( !ok )
@ -783,7 +777,6 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
#if defined( __CYGWIN__ ) && defined( __WINDOWS__ ) #if defined( __CYGWIN__ ) && defined( __WINDOWS__ )
// another example of DOS/Unix mix (Cygwin) // another example of DOS/Unix mix (Cygwin)
wxString pathUnix = buf; wxString pathUnix = buf;
#if wxUSE_UNICODE
#if CYGWIN_VERSION_DLL_MAJOR >= 1007 #if CYGWIN_VERSION_DLL_MAJOR >= 1007
cygwin_conv_path(CCP_POSIX_TO_WIN_W, pathUnix.mb_str(wxConvFile), buf, sz); cygwin_conv_path(CCP_POSIX_TO_WIN_W, pathUnix.mb_str(wxConvFile), buf, sz);
#else #else
@ -791,22 +784,10 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz)
cygwin_conv_to_full_win32_path(pathUnix.mb_str(wxConvFile), bufA); cygwin_conv_to_full_win32_path(pathUnix.mb_str(wxConvFile), bufA);
wxConvFile.MB2WC(buf, bufA, sz); wxConvFile.MB2WC(buf, bufA, sz);
#endif #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__ #endif // __CYGWIN__
} }
return buf; return buf;
#if !wxUSE_UNICODE
#undef cbuf
#endif
} }
wxString wxGetCwd() wxString wxGetCwd()

View file

@ -211,14 +211,9 @@ wxHTTP::SetPostText(const wxString& contentType,
const wxString& data, const wxString& data,
const wxMBConv& conv) const wxMBConv& conv)
{ {
#if wxUSE_UNICODE
wxScopedCharBuffer scb = data.mb_str(conv); wxScopedCharBuffer scb = data.mb_str(conv);
const size_t len = scb.length(); const size_t len = scb.length();
const char* const buf = scb.data(); 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 ) if ( !len )
return false; return false;

View file

@ -51,7 +51,7 @@
#endif // wxCrtSetDbgFlag #endif // wxCrtSetDbgFlag
#endif // __WINDOWS__ #endif // __WINDOWS__
#if wxUSE_UNICODE && defined(__WXOSX__) #if defined(__WXOSX__)
#include <locale.h> #include <locale.h>
#endif #endif
@ -132,10 +132,8 @@ static struct InitData
InitData() InitData()
: nInitCount(0) : nInitCount(0)
{ {
#if wxUSE_UNICODE
argc = argcOrig = 0; argc = argcOrig = 0;
// argv = argvOrig = nullptr; -- not even really needed // argv = argvOrig = nullptr; -- not even really needed
#endif // wxUSE_UNICODE
} }
// number of times wxInitialize() was called minus the number of times // 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 // only one of them to actually initialize the library
wxAtomicInt nInitCount; wxAtomicInt nInitCount;
#if wxUSE_UNICODE
int argc; int argc;
// if we receive the command line arguments as ASCII and have to convert // 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 // the latter to be able to free everything correctly
int argcOrig; int argcOrig;
wchar_t **argvOrig; wchar_t **argvOrig;
#endif // wxUSE_UNICODE
wxDECLARE_NO_COPY_CLASS(InitData); wxDECLARE_NO_COPY_CLASS(InitData);
} gs_initData; } gs_initData;
@ -172,8 +168,6 @@ static struct InitData
// command line arguments ANSI -> Unicode conversion // command line arguments ANSI -> Unicode conversion
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE
static void ConvertArgsToUnicode(int argc, char **argv) static void ConvertArgsToUnicode(int argc, char **argv)
{ {
gs_initData.argvOrig = new wchar_t *[argc + 1]; gs_initData.argvOrig = new wchar_t *[argc + 1];
@ -219,8 +213,6 @@ static void FreeConvertedArgs()
} }
} }
#endif // wxUSE_UNICODE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// start up // start up
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -228,7 +220,7 @@ static void FreeConvertedArgs()
// initialization which is always done (not customizable) before wxApp creation // initialization which is always done (not customizable) before wxApp creation
static bool DoCommonPreInit() 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 // 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 // some locales. The safest fix is to set LC_CTYPE to UTF-8 to ensure that
// they can handle any input. // 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 // See https://stackoverflow.com/questions/11713745/why-does-the-printf-family-of-functions-care-about-locale
setlocale(LC_CTYPE, "UTF-8"); setlocale(LC_CTYPE, "UTF-8");
#endif // wxUSE_UNICODE && defined(__WXOSX__) #endif // defined(__WXOSX__)
#if wxUSE_LOG #if wxUSE_LOG
// Reset logging in case we were cleaned up and are being reinitialized. // 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 // remember, possibly modified (e.g. due to removal of toolkit-specific
// parameters), command line arguments in member variables // parameters), command line arguments in member variables
app->argc = argc; app->argc = argc;
#if wxUSE_UNICODE
app->argv.Init(argc, argv); app->argv.Init(argc, argv);
#else
app->argv = argv;
#endif
wxCallAppCleanup callAppCleanup(app.get()); wxCallAppCleanup callAppCleanup(app.get());
@ -365,8 +353,6 @@ bool wxEntryStart(int& argc, wxChar **argv)
return true; return true;
} }
#if wxUSE_UNICODE
// we provide a wxEntryStart() wrapper taking "char *" pointer too // we provide a wxEntryStart() wrapper taking "char *" pointer too
bool wxEntryStart(int& argc, char **argv) bool wxEntryStart(int& argc, char **argv)
{ {
@ -382,8 +368,6 @@ bool wxEntryStart(int& argc, char **argv)
return true; return true;
} }
#endif // wxUSE_UNICODE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// clean up // 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 // we can't do this in wxApp itself because it doesn't know if argv had
// been allocated // been allocated
#if wxUSE_UNICODE
FreeConvertedArgs(); FreeConvertedArgs();
#endif // wxUSE_UNICODE
// use Set(nullptr) and not Get() to avoid creating a message output object on // use Set(nullptr) and not Get() to avoid creating a message output object on
// demand when we just want to delete it // demand when we just want to delete it
@ -505,8 +487,6 @@ int wxEntryReal(int& argc, wxChar **argv)
wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; ) wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
} }
#if wxUSE_UNICODE
// as with wxEntryStart, we provide an ANSI wrapper // as with wxEntryStart, we provide an ANSI wrapper
int wxEntry(int& argc, char **argv) int wxEntry(int& argc, char **argv)
{ {
@ -515,8 +495,6 @@ int wxEntry(int& argc, char **argv)
return wxEntry(gs_initData.argc, gs_initData.argv); return wxEntry(gs_initData.argc, gs_initData.argv);
} }
#endif // wxUSE_UNICODE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxInitialize/wxUninitialize // wxInitialize/wxUninitialize
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -538,7 +516,6 @@ bool wxInitialize(int& argc, wxChar **argv)
return wxEntryStart(argc, argv); return wxEntryStart(argc, argv);
} }
#if wxUSE_UNICODE
bool wxInitialize(int& argc, char **argv) bool wxInitialize(int& argc, char **argv)
{ {
if ( wxAtomicInc(gs_initData.nInitCount) != 1 ) if ( wxAtomicInc(gs_initData.nInitCount) != 1 )
@ -549,7 +526,6 @@ bool wxInitialize(int& argc, char **argv)
return wxEntryStart(argc, argv); return wxEntryStart(argc, argv);
} }
#endif // wxUSE_UNICODE
void wxUninitialize() void wxUninitialize()
{ {

View file

@ -461,7 +461,7 @@ bool wxLocale::Init(int lang, int flags)
const char *retloc = lang == wxLANGUAGE_DEFAULT ? wxSetlocale(LC_ALL, "") const char *retloc = lang == wxLANGUAGE_DEFAULT ? wxSetlocale(LC_ALL, "")
: info->TrySetLocale(); : 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 // VC++ setlocale() (also used by Mingw) can't set locale to languages that
// can only be written using Unicode, therefore wxSetlocale() call fails // 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 // 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(); wxTranslations *t = wxTranslations::Get();
if ( !t ) if ( !t )
return false; return false;
#if wxUSE_UNICODE
wxUnusedVar(msgIdCharset); wxUnusedVar(msgIdCharset);
return t->AddCatalog(szDomain, msgIdLanguage); return t->AddCatalog(szDomain, msgIdLanguage);
#else
return t->AddCatalog(szDomain, msgIdLanguage, msgIdCharset);
#endif
} }
bool wxLocale::IsLoaded(const wxString& domain) const bool wxLocale::IsLoaded(const wxString& domain) const

View file

@ -79,7 +79,6 @@ wxString wxConnectionBase::GetTextFromData(const void* data,
s = wxString(static_cast<const char *>(data), size); s = wxString(static_cast<const char *>(data), size);
break; break;
#if wxUSE_UNICODE
// TODO: we should handle both wxIPC_UTF16TEXT and wxIPC_UTF32TEXT here // TODO: we should handle both wxIPC_UTF16TEXT and wxIPC_UTF32TEXT here
// for inter-platform IPC // for inter-platform IPC
case wxIPC_UNICODETEXT: case wxIPC_UNICODETEXT:
@ -99,7 +98,6 @@ wxString wxConnectionBase::GetTextFromData(const void* data,
s = wxString::FromUTF8(static_cast<const char *>(data), size); s = wxString::FromUTF8(static_cast<const char *>(data), size);
break; break;
#endif // wxUSE_UNICODE
default: default:
wxFAIL_MSG( "non-string IPC format in GetTextFromData()" ); wxFAIL_MSG( "non-string IPC format in GetTextFromData()" );

View file

@ -52,7 +52,7 @@
#if wxUSE_PCRE #if wxUSE_PCRE
// Use the same code unit width for PCRE as we use for wxString. // 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 # define PCRE2_CODE_UNIT_WIDTH 8
typedef char wxRegChar; typedef char wxRegChar;
# elif wxUSE_UNICODE_UTF16 # elif wxUSE_UNICODE_UTF16
@ -280,9 +280,7 @@ typedef char wxRegErrorChar;
return regexec(preg, string, nmatch, pmatch, eflags); return regexec(preg, string, nmatch, pmatch, eflags);
} }
# endif # endif
# if wxUSE_UNICODE # define WXREGEX_CONVERT_TO_MB
# define WXREGEX_CONVERT_TO_MB
# endif
# define wx_regcomp regcomp # define wx_regcomp regcomp
# define wx_regfree regfree # define wx_regfree regfree
# define wx_regerror regerror # define wx_regerror regerror

View file

@ -35,16 +35,10 @@
// TODO: Do we want to include the null char in the stream? If so then // TODO: Do we want to include the null char in the stream? If so then
// just add +1 to m_len in the ctor // just add +1 to m_len in the ctor
wxStringInputStream::wxStringInputStream(const wxString& s) wxStringInputStream::wxStringInputStream(const wxString& s)
#if wxUSE_UNICODE
// FIXME-UTF8: use wxCharBufferWithLength if we have it // FIXME-UTF8: use wxCharBufferWithLength if we have it
: m_str(s), m_buf(s.utf8_str()), m_len(strlen(m_buf)) : 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!")); wxASSERT_MSG(m_buf.data() != nullptr, wxT("Could not convert string to UTF8!"));
#endif
m_pos = 0; m_pos = 0;
} }
@ -127,13 +121,10 @@ size_t wxStringInputStream::OnSysRead(void *buffer, size_t size)
wxStringOutputStream::wxStringOutputStream(wxString *pString, wxMBConv& conv) wxStringOutputStream::wxStringOutputStream(wxString *pString, wxMBConv& conv)
: m_conv(conv) : m_conv(conv)
#if wxUSE_UNICODE
, m_unconv(0) , m_unconv(0)
#endif // wxUSE_UNICODE
{ {
m_str = pString ? pString : &m_strInternal; m_str = pString ? pString : &m_strInternal;
#if wxUSE_UNICODE
// We can avoid doing the conversion in the common case of using UTF-8 // 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 // conversion in UTF-8 build, as it is exactly the same as the string
// length anyhow in this case. // length anyhow in this case.
@ -143,9 +134,6 @@ wxStringOutputStream::wxStringOutputStream(wxString *pString, wxMBConv& conv)
else else
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
m_pos = m_conv.FromWChar(nullptr, 0, m_str->wc_str(), m_str->length()); 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<const char *>(buffer); const char *p = static_cast<const char *>(buffer);
#if wxUSE_UNICODE
// the part of the string we have here may be incomplete, i.e. it can stop // 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 // 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 // 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 // not update m_pos as m_str hasn't changed
return size; return size;
} }
#else // !wxUSE_UNICODE
// no recoding necessary
m_str->append(p, size);
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
// update position // update position
m_pos += size; m_pos += size;

View file

@ -188,7 +188,7 @@ static wxStrCacheStatsDumper s_showCacheStats;
wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str)
{ {
#if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 #if !wxUSE_UNICODE_UTF8
return os << wxConvWhateverWorks.cWX2MB(str); return os << wxConvWhateverWorks.cWX2MB(str);
#else #else
return os << str.AsInternal(); return os << str.AsInternal();
@ -214,7 +214,7 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str)
return os << wxConvWhateverWorks.cWC2MB(str.data()); 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) 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(); return wos << str.data();
} }
#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM) #endif // defined(HAVE_WOSTREAM)
#endif // wxUSE_STD_IOSTREAM #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, // NB: non-STL implementation doesn't compile with "const wxString*" key type,
// so we have to use wxString* here and const-cast when used // so we have to use wxString* here and const-cast when used
WX_DECLARE_HASH_MAP(wxString*, char*, wxPointerHash, wxPointerEqual, WX_DECLARE_HASH_MAP(wxString*, char*, wxPointerHash, wxPointerEqual,
@ -332,7 +331,6 @@ const char* wxCStrData::AsChar() const
return s + m_offset; return s + m_offset;
} }
#endif // wxUSE_UNICODE
#if !wxUSE_UNICODE_WCHAR #if !wxUSE_UNICODE_WCHAR
WX_DECLARE_HASH_MAP(wxString*, wchar_t*, wxPointerHash, wxPointerEqual, WX_DECLARE_HASH_MAP(wxString*, wchar_t*, wxPointerHash, wxPointerEqual,
@ -354,10 +352,8 @@ const wchar_t* wxCStrData::AsWChar() const
wxString::~wxString() wxString::~wxString()
{ {
#if wxUSE_UNICODE
// FIXME-UTF8: do this only if locale is not UTF8 if wxUSE_UNICODE_UTF8 // FIXME-UTF8: do this only if locale is not UTF8 if wxUSE_UNICODE_UTF8
DeleteStringFromConversionCache(gs_stringsCharCache, this); DeleteStringFromConversionCache(gs_stringsCharCache, this);
#endif
#if !wxUSE_UNICODE_WCHAR #if !wxUSE_UNICODE_WCHAR
DeleteStringFromConversionCache(gs_stringsWCharCache, this); DeleteStringFromConversionCache(gs_stringsWCharCache, this);
#endif #endif
@ -437,7 +433,7 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
} }
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
#if wxUSE_UNICODE_UTF8 || !wxUSE_UNICODE #if wxUSE_UNICODE_UTF8
/* static */ /* static */
wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLength, wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLength,
const wxMBConv& conv) const wxMBConv& conv)
@ -456,7 +452,7 @@ wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLengt
else else
return SubstrBufFromWC(mbBuf, mbLen); 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 // 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 // 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 // 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 // non-ANSI build except if we need to convert to UTF-8 and this is what we
// already use internally. // already use internally.
#if wxUSE_UNICODE
const char *wxString::AsChar(const wxMBConv& conv) const const char *wxString::AsChar(const wxMBConv& conv) const
{ {
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
@ -548,8 +542,6 @@ const char *wxString::AsChar(const wxMBConv& conv) const
return m_convertedToChar.m_str; return m_convertedToChar.m_str;
} }
#endif // wxUSE_UNICODE
// shrink to minimal size (releasing extra memory) // shrink to minimal size (releasing extra memory)
bool wxString::Shrink() 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 // the functions above were implemented for wchar_t* arguments in Unicode
// build and char* in ANSI build; below are implementations for the other // build; below are implementations for the char* arguments
// version: size_t wxString::find_first_of(const char* sz, size_t nStart) const
#if wxUSE_UNICODE { return find_first_of(wxConvLibc.cMB2WC(sz), nStart); }
#define wxOtherCharType char
#define STRCONV (const wxChar*)wxConvLibc.cMB2WC
#else
#define wxOtherCharType wchar_t
#define STRCONV (const wxChar*)wxConvLibc.cWC2MB
#endif
size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart) const size_t wxString::find_first_of(const char* sz, size_t nStart,
{ return find_first_of(STRCONV(sz), nStart); }
size_t wxString::find_first_of(const wxOtherCharType* sz, size_t nStart,
size_t n) const size_t n) const
{ return find_first_of(STRCONV(sz, n, nullptr), nStart, n); } { return find_first_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); }
size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart) const size_t wxString::find_last_of(const char* sz, size_t nStart) const
{ return find_last_of(STRCONV(sz), nStart); } { return find_last_of(wxConvLibc.cMB2WC(sz), nStart); }
size_t wxString::find_last_of(const wxOtherCharType* sz, size_t nStart, size_t wxString::find_last_of(const char* sz, size_t nStart,
size_t n) const size_t n) const
{ return find_last_of(STRCONV(sz, n, nullptr), nStart, n); } { return find_last_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); }
size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart) const size_t wxString::find_first_not_of(const char* sz, size_t nStart) const
{ return find_first_not_of(STRCONV(sz), nStart); } { return find_first_not_of(wxConvLibc.cMB2WC(sz), nStart); }
size_t wxString::find_first_not_of(const wxOtherCharType* sz, size_t nStart, size_t wxString::find_first_not_of(const char* sz, size_t nStart,
size_t n) const size_t n) const
{ return find_first_not_of(STRCONV(sz, n, nullptr), nStart, n); } { return find_first_not_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); }
size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart) const size_t wxString::find_last_not_of(const char* sz, size_t nStart) const
{ return find_last_not_of(STRCONV(sz), nStart); } { return find_last_not_of(wxConvLibc.cMB2WC(sz), nStart); }
size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart, size_t wxString::find_last_not_of(const char* sz, size_t nStart,
size_t n) const size_t n) const
{ return find_last_not_of(STRCONV(sz, n, nullptr), nStart, n); } { return find_last_not_of(wxConvLibc.cMB2WC(sz, n, nullptr), nStart, n); }
#undef wxOtherCharType
#undef STRCONV
#endif // !wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 #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 wxString::FromAscii(const char *ascii, size_t len)
{ {
wxString res; wxString res;
@ -1201,8 +1179,6 @@ const wxScopedCharBuffer wxString::ToAscii(char replaceWith) const
return buffer; return buffer;
} }
#endif // wxUSE_UNICODE
// extract string of length nCount starting at nFirst // extract string of length nCount starting at nFirst
wxString wxString::Mid(size_t nFirst, size_t nCount) const 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") ); wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
WX_STRING_TO_X_TYPE_START 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); long val = wxStrtol_lA(start, &end, base, wxCLocale);
#else #else
long val = wxStrtol_l(start, &end, base, wxCLocale); 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") ); wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
WX_STRING_TO_X_TYPE_START 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); unsigned long val = wxStrtoul_lA(start, &end, base, wxCLocale);
#else #else
unsigned long val = wxStrtoul_l(start, &end, base, wxCLocale); 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 bool wxString::ToCDouble(double *pVal) const
{ {
WX_STRING_TO_X_TYPE_START 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); double val = wxStrtod_lA(start, &end, wxCLocale);
#else #else
double val = wxStrtod_l(start, &end, wxCLocale); double val = wxStrtod_l(start, &end, wxCLocale);

View file

@ -26,7 +26,7 @@
// implementation // implementation
// =========================================================================== // ===========================================================================
#if wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE #if wxUSE_UNICODE_WCHAR
#if wxUSE_UNICODE_UTF16 #if wxUSE_UNICODE_UTF16
@ -88,7 +88,7 @@ wxWxCharBuffer wxStringOperationsWchar::EncodeNChars(size_t n, const wxUniChar&
#endif // wxUSE_UNICODE_UTF16 #endif // wxUSE_UNICODE_UTF16
#endif // wxUSE_UNICODE_WCHAR || !wxUSE_UNICODE #endif // wxUSE_UNICODE_WCHAR
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8

View file

@ -493,27 +493,6 @@ class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase<char>
}; };
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
#if !wxUSE_UNICODE // FIXME-UTF8: remove
class wxPrintfFormatConverterANSI : public wxFormatConverterBase<char>
{
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__ #ifndef __WINDOWS__
/* /*
@ -605,17 +584,13 @@ const char* wxFormatString::InputAsChar()
const char* wxFormatString::AsChar() const char* wxFormatString::AsChar()
{ {
if ( !m_convertedChar ) if ( !m_convertedChar )
#if !wxUSE_UNICODE // FIXME-UTF8: remove this
m_convertedChar = wxPrintfFormatConverterANSI().Convert(InputAsChar());
#else
m_convertedChar = wxPrintfFormatConverterUtf8().Convert(InputAsChar()); m_convertedChar = wxPrintfFormatConverterUtf8().Convert(InputAsChar());
#endif
return m_convertedChar.data(); return m_convertedChar.data();
} }
#endif // !wxUSE_UNICODE_WCHAR #endif // !wxUSE_UNICODE_WCHAR
#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
const wchar_t* wxFormatString::InputAsWChar() const wchar_t* wxFormatString::InputAsWChar()
{ {
if ( m_wchar ) if ( m_wchar )
@ -655,7 +630,7 @@ const wchar_t* wxFormatString::AsWChar()
return m_convertedWChar.data(); return m_convertedWChar.data();
} }
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #endif // !wxUSE_UTF8_LOCALE_ONLY
wxString wxFormatString::InputAsString() const wxString wxFormatString::InputAsString() const
{ {

View file

@ -274,7 +274,6 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
{ {
bool badconv = false; bool badconv = false;
#if wxUSE_UNICODE
wxCharBuffer nameBuf = name.mb_str(conv); wxCharBuffer nameBuf = name.mb_str(conv);
// if the conversion fails make an approximation // if the conversion fails make an approximation
@ -291,10 +290,6 @@ bool wxTarHeaderBlock::SetPath(const wxString& name, wxMBConv& conv)
} }
const char *mbName = nameBuf; const char *mbName = nameBuf;
#else
const char *mbName = name.c_str();
(void)conv;
#endif
bool fits; bool fits;
bool notGoingToFit = false; bool notGoingToFit = false;
@ -1434,16 +1429,8 @@ void wxTarOutputStream::SetExtendedHeader(const wxString& key,
const wxString& value) const wxString& value)
{ {
if (m_pax) { if (m_pax) {
#if wxUSE_UNICODE
const wxCharBuffer utf_key = key.utf8_str(); const wxCharBuffer utf_key = key.utf8_str();
const wxCharBuffer utf_value = value.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 // a small buffer to format the length field in
char buf[32]; char buf[32];

View file

@ -1142,14 +1142,11 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
break; break;
default: default:
#if wxUSE_UNICODE
if ( event.GetUnicodeKey() ) if ( event.GetUnicodeKey() )
{ {
ch = event.GetUnicodeKey(); ch = event.GetUnicodeKey();
} }
else else if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
#endif
if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
{ {
// FIXME this is not going to work for non letters... // FIXME this is not going to work for non letters...
if ( !event.ShiftDown() ) if ( !event.ShiftDown() )

View file

@ -313,9 +313,7 @@ bool wxTextEntryBase::CanPaste() const
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
// check if there is any text on the clipboard // check if there is any text on the clipboard
if ( wxTheClipboard->IsSupported(wxDF_TEXT) if ( wxTheClipboard->IsSupported(wxDF_TEXT)
#if wxUSE_UNICODE
|| wxTheClipboard->IsSupported(wxDF_UNICODETEXT) || wxTheClipboard->IsSupported(wxDF_UNICODETEXT)
#endif // wxUSE_UNICODE
) )
{ {
return true; return true;

View file

@ -126,11 +126,7 @@ void wxStringTokenizer::SetString(const wxString& str,
} }
} }
#if wxUSE_UNICODE // FIXME-UTF8: only wc_str()
m_delims = delims.wc_str(); m_delims = delims.wc_str();
#else
m_delims = delims.mb_str();
#endif
m_delimsLen = delims.length(); m_delimsLen = delims.length();
m_mode = mode; m_mode = mode;

View file

@ -79,13 +79,6 @@ const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
namespace 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 // Platform specific helpers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1132,39 +1125,19 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash,
if ( !m_charset.empty() ) if ( !m_charset.empty() )
{ {
#if !wxUSE_UNICODE && wxUSE_FONTMAP inputConv = new wxCSConv(m_charset);
// determine if we need any conversion at all
wxFontEncoding encCat = wxFontMapperBase::GetEncodingFromName(m_charset);
if ( encCat != wxLocale::GetSystemEncoding() )
#endif
{
inputConv = new wxCSConv(m_charset);
// As we allocated it ourselves, we need to delete it, so ensure // As we allocated it ourselves, we need to delete it, so ensure
// this happens. // this happens.
inputConvPtr.reset(inputConv); 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 // we must somehow convert the narrow strings in the message catalog to
// wide strings, so use the default conversion if we have no charset // wide strings, so use the default conversion if we have no charset
inputConv = wxConvCurrent; 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<wxCSConv> sourceConv;
if ( !msgIdCharset.empty() && (msgIdCharset != m_charset) )
sourceConv.reset(new wxCSConv(msgIdCharset));
#endif // !wxUSE_UNICODE
for (size_t32 i = 0; i < m_numStrings; i++) for (size_t32 i = 0; i < m_numStrings; i++)
{ {
const char *data = StringAtOfs(m_pOrigTable, 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 return false; // may happen for invalid MO files
wxString msgid; wxString msgid;
#if wxUSE_UNICODE
msgid = wxString(data, *inputConv); 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); data = StringAtOfs(m_pTransTable, i);
if (!data) if (!data)
return false; // may happen for invalid MO files return false; // may happen for invalid MO files
@ -1193,15 +1158,7 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash,
const char * const str = data + offset; const char * const str = data + offset;
wxString msgstr; wxString msgstr;
#if wxUSE_UNICODE
msgstr = wxString(str, *inputConv); msgstr = wxString(str, *inputConv);
#else
if ( inputConv )
msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI);
else
msgstr = str;
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
if ( !msgstr.empty() ) if ( !msgstr.empty() )
{ {
hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr; hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr;
@ -1226,23 +1183,6 @@ bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash,
// wxMsgCatalog class // 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 */ /* static */
wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename, wxMsgCatalog *wxMsgCatalog::CreateFromFile(const wxString& filename,
const wxString& domain) const wxString& domain)
@ -1415,16 +1355,6 @@ bool wxTranslations::AddStdCatalog()
return false; 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, bool wxTranslations::AddCatalog(const wxString& domain,
wxLanguage msgIdLanguage) wxLanguage msgIdLanguage)
{ {

View file

@ -26,7 +26,6 @@
// wxTextInputStream // wxTextInputStream
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE
wxTextInputStream::wxTextInputStream(wxInputStream &s, wxTextInputStream::wxTextInputStream(wxInputStream &s,
const wxString &sep, const wxString &sep,
const wxMBConv& conv) const wxMBConv& conv)
@ -39,22 +38,10 @@ wxTextInputStream::wxTextInputStream(wxInputStream &s,
m_lastWChar = 0; m_lastWChar = 0;
#endif // SIZEOF_WCHAR_T == 2 #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() wxTextInputStream::~wxTextInputStream()
{ {
#if wxUSE_UNICODE
delete m_conv; delete m_conv;
#endif // wxUSE_UNICODE
} }
void wxTextInputStream::UngetLast() void wxTextInputStream::UngetLast()
@ -70,7 +57,6 @@ void wxTextInputStream::UngetLast()
wxChar wxTextInputStream::GetChar() wxChar wxTextInputStream::GetChar()
{ {
#if wxUSE_UNICODE
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
// Return the already raed character remaining from the last call to this // Return the already raed character remaining from the last call to this
// function, if any. // function, if any.
@ -169,20 +155,6 @@ wxChar wxTextInputStream::GetChar()
m_validEnd = sizeof(m_lastBytes); m_validEnd = sizeof(m_lastBytes);
return 0; 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() wxChar wxTextInputStream::NextNonSeparators()
@ -377,7 +349,7 @@ wxTextInputStream& wxTextInputStream::operator>>(char& c)
return *this; return *this;
} }
#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE #if wxWCHAR_T_IS_REAL_TYPE
wxTextInputStream& wxTextInputStream::operator>>(wchar_t& wc) wxTextInputStream& wxTextInputStream::operator>>(wchar_t& wc)
{ {
@ -386,7 +358,7 @@ wxTextInputStream& wxTextInputStream::operator>>(wchar_t& wc)
return *this; return *this;
} }
#endif // wxUSE_UNICODE #endif // wxWCHAR_T_IS_REAL_TYPE
wxTextInputStream& wxTextInputStream::operator>>(wxInt16& i) wxTextInputStream& wxTextInputStream::operator>>(wxInt16& i)
{ {
@ -438,15 +410,10 @@ wxTextInputStream& wxTextInputStream::operator>>(float& f)
#if wxUSE_UNICODE
wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxTextOutputStream::wxTextOutputStream(wxOutputStream& s,
wxEOL mode, wxEOL mode,
const wxMBConv& conv) const wxMBConv& conv)
: m_output(s), m_conv(conv.Clone()) : m_output(s), m_conv(conv.Clone())
#else
wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode)
: m_output(s)
#endif
{ {
m_mode = mode; m_mode = mode;
if (m_mode == wxEOL_NATIVE) if (m_mode == wxEOL_NATIVE)
@ -458,16 +425,14 @@ wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode)
#endif #endif
} }
#if wxUSE_UNICODE && SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
m_lastWChar = 0; m_lastWChar = 0;
#endif // SIZEOF_WCHAR_T == 2 #endif // SIZEOF_WCHAR_T == 2
} }
wxTextOutputStream::~wxTextOutputStream() wxTextOutputStream::~wxTextOutputStream()
{ {
#if wxUSE_UNICODE
delete m_conv; delete m_conv;
#endif // wxUSE_UNICODE
} }
void wxTextOutputStream::SetMode(wxEOL mode) void wxTextOutputStream::SetMode(wxEOL mode)
@ -555,18 +520,13 @@ void wxTextOutputStream::WriteString(const wxString& string)
out << c; out << c;
} }
#if wxUSE_UNICODE
// FIXME-UTF8: use wxCharBufferWithLength if/when we have it // FIXME-UTF8: use wxCharBufferWithLength if/when we have it
wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len); wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len);
m_output.Write(buffer, len); m_output.Write(buffer, len);
#else
m_output.Write(out.c_str(), out.length() );
#endif
} }
wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c) wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c)
{ {
#if wxUSE_UNICODE
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
wxCharBuffer buffer; wxCharBuffer buffer;
size_t len; size_t len;
@ -627,15 +587,11 @@ wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c)
#else // SIZEOF_WCHAR_T == 4 #else // SIZEOF_WCHAR_T == 4
WriteString( wxString(&c, *m_conv, 1) ); WriteString( wxString(&c, *m_conv, 1) );
#endif // SIZEOF_WCHAR_T == 2 or 4 #endif // SIZEOF_WCHAR_T == 2 or 4
#else
WriteString( wxString(&c, wxConvLocal, 1) );
#endif
return *this; return *this;
} }
void wxTextOutputStream::Flush() void wxTextOutputStream::Flush()
{ {
#if wxUSE_UNICODE
const size_t len = m_conv->FromWChar(nullptr, 0, L"", 1); const size_t len = m_conv->FromWChar(nullptr, 0, L"", 1);
if ( len > m_conv->GetMBNulLen() ) if ( len > m_conv->GetMBNulLen() )
{ {
@ -643,7 +599,6 @@ void wxTextOutputStream::Flush()
m_conv->FromWChar(buf.data(), len, L"", 1); m_conv->FromWChar(buf.data(), len, L"", 1);
m_output.Write(buf, len - m_conv->GetMBNulLen()); m_output.Write(buf, len - m_conv->GetMBNulLen());
} }
#endif // wxUSE_UNICODE
} }
wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string) wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string)
@ -659,7 +614,7 @@ wxTextOutputStream& wxTextOutputStream::operator<<(char c)
return *this; return *this;
} }
#if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE #if wxWCHAR_T_IS_REAL_TYPE
wxTextOutputStream& wxTextOutputStream::operator<<(wchar_t wc) wxTextOutputStream& wxTextOutputStream::operator<<(wchar_t wc)
{ {
@ -668,7 +623,7 @@ wxTextOutputStream& wxTextOutputStream::operator<<(wchar_t wc)
return *this; return *this;
} }
#endif // wxUSE_UNICODE #endif // wxWCHAR_T_IS_REAL_TYPE
wxTextOutputStream& wxTextOutputStream::operator<<(wxInt16 c) wxTextOutputStream& wxTextOutputStream::operator<<(wxInt16 c)
{ {

View file

@ -1391,10 +1391,8 @@ wxVersionInfo wxGetLibraryVersionInfo()
wxRELEASE_NUMBER, wxRELEASE_NUMBER,
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
"UTF-8", "UTF-8",
#elif wxUSE_UNICODE
"wchar_t",
#else #else
"none", "wchar_t",
#endif #endif
wxDEBUG_LEVEL, wxDEBUG_LEVEL,
#if !wxUSE_REPRODUCIBLE_BUILD #if !wxUSE_REPRODUCIBLE_BUILD

View file

@ -150,7 +150,6 @@ void wxNumValidatorBase::OnChar(wxKeyEvent& event)
if ( !m_validatorWindow ) if ( !m_validatorWindow )
return; return;
#if wxUSE_UNICODE
const int ch = event.GetUnicodeKey(); const int ch = event.GetUnicodeKey();
if ( ch == WXK_NONE ) if ( ch == WXK_NONE )
{ {
@ -158,14 +157,6 @@ void wxNumValidatorBase::OnChar(wxKeyEvent& event)
// arrow or function key, we never filter those. // arrow or function key, we never filter those.
return; 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 ) if ( ch < WXK_SPACE || ch == WXK_DELETE )
{ {

View file

@ -280,14 +280,8 @@ void wxTextValidator::OnChar(wxKeyEvent& event)
if (!m_validatorWindow) if (!m_validatorWindow)
return; return;
#if wxUSE_UNICODE
// We only filter normal, printable characters. // We only filter normal, printable characters.
int keyCode = event.GetUnicodeKey(); 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 // we don't filter special keys and delete
if (keyCode < WXK_SPACE || keyCode == WXK_DELETE) if (keyCode < WXK_SPACE || keyCode == WXK_DELETE)

View file

@ -448,8 +448,6 @@ int wxDoSprintfUtf8(char *str, const char *format, ...)
} }
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
#if wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...) 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_UTF8
#endif // wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...) 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 #endif // wxUSE_UNICODE_UTF8
#if wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY #if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...) 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_UTF8
#endif // wxUSE_UNICODE
#ifdef HAVE_BROKEN_VSNPRINTF_DECL #ifdef HAVE_BROKEN_VSNPRINTF_DECL
#define vsnprintf wx_fixed_vsnprintf #define vsnprintf wx_fixed_vsnprintf
#endif #endif
#if wxUSE_UNICODE
namespace namespace
{ {
@ -593,7 +583,6 @@ static size_t PrintfViaString(T *out, size_t outsize,
return ConvertStringToBuf(s, out, outsize); return ConvertStringToBuf(s, out, outsize);
} }
#endif // wxUSE_UNICODE
int wxVsprintf(char *str, const wxString& format, va_list argptr) 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); return wxCRT_VsprintfA(str, format.wx_str(), argptr);
else else
#endif #endif
#if wxUSE_UNICODE
return PrintfViaString(str, wxNO_LEN, format, argptr); return PrintfViaString(str, wxNO_LEN, format, argptr);
#else
return wxCRT_VsprintfA(str, format.mb_str(), argptr);
#endif
#endif #endif
} }
#if wxUSE_UNICODE
int wxVsprintf(wchar_t *str, const wxString& format, va_list argptr) int wxVsprintf(wchar_t *str, const wxString& format, va_list argptr)
{ {
#if wxUSE_UNICODE_WCHAR #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); return PrintfViaString(str, wxNO_LEN, format, argptr);
#endif // wxUSE_UNICODE_UTF8 #endif // wxUSE_UNICODE_UTF8
} }
#endif // wxUSE_UNICODE
int wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr) 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); rv = wxCRT_VsnprintfA(str, size, format.wx_str(), argptr);
else else
#endif #endif
#if wxUSE_UNICODE
{ {
// NB: if this code is called, then wxString::PrintV() would use the // NB: if this code is called, then wxString::PrintV() would use the
// wchar_t* version of wxVsnprintf(), so it's safe to use PrintV() // wchar_t* version of wxVsnprintf(), so it's safe to use PrintV()
// from here // from here
rv = PrintfViaString(str, size, format, argptr); rv = PrintfViaString(str, size, format, argptr);
} }
#else
rv = wxCRT_VsnprintfA(str, size, format.mb_str(), argptr);
#endif
#endif #endif
// VsnprintfTestCase reveals that glibc's implementation of vswprintf // 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; return rv;
} }
#if wxUSE_UNICODE
int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr) int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr)
{ {
int rv; int rv;
@ -687,8 +665,6 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt
return rv; return rv;
} }
#endif // wxUSE_UNICODE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ctype.h stuff (currently unused) // ctype.h stuff (currently unused)
@ -1173,13 +1149,9 @@ int wxFputs(const wxString& s, FILE *stream)
int wxFputc(const wxUniChar& c, 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, CALL_ANSI_OR_UNICODE(return,
wxCRT_FputsA(c.AsUTF8(), stream), wxCRT_FputsA(c.AsUTF8(), stream),
wxCRT_FputcW((wchar_t)c, stream)); wxCRT_FputcW((wchar_t)c, stream));
#endif
} }
#ifdef wxCRT_PerrorA #ifdef wxCRT_PerrorA

View file

@ -294,13 +294,8 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *ca
createParamOids = new int[classInfo->GetCreateParamCount() ]; createParamOids = new int[classInfo->GetCreateParamCount() ];
createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ]; createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ];
#if wxUSE_UNICODE
typedef map<wstring, wxXmlNode *> PropertyNodes; typedef map<wstring, wxXmlNode *> PropertyNodes;
typedef vector<wstring> PropertyNames; typedef vector<wstring> PropertyNames;
#else
typedef map<string, wxXmlNode *> PropertyNodes;
typedef vector<string> PropertyNames;
#endif
PropertyNodes propertyNodes; PropertyNodes propertyNodes;
PropertyNames propertyNames; PropertyNames propertyNames;

View file

@ -89,18 +89,9 @@ static wxString ReadString(wxInputStream& stream, wxUint16 len, wxMBConv& conv)
if (len == 0) if (len == 0)
return wxEmptyString; return wxEmptyString;
#if wxUSE_UNICODE
wxCharBuffer buf(len); wxCharBuffer buf(len);
stream.Read(buf.data(), len); stream.Read(buf.data(), len);
wxString str(buf, conv); wxString str(buf, conv);
#else
wxString str;
(void)conv;
{
wxStringBuffer buf(str, len);
stream.Read(buf, len);
}
#endif
return str; return str;
} }

View file

@ -41,7 +41,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
// is just a temporary fix to make wxDFB compile in Unicode // is just a temporary fix to make wxDFB compile in Unicode
// build, the real fix is to change Initialize()'s signature // build, the real fix is to change Initialize()'s signature
// to use char* on Unix. // to use char* on Unix.
#if wxUSE_UNICODE
// DirectFBInit() wants UTF-8, not wchar_t, so convert // DirectFBInit() wants UTF-8, not wchar_t, so convert
int i; int i;
char **argvDFB = new char *[argc + 1]; char **argvDFB = new char *[argc + 1];
@ -80,20 +79,9 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
delete [] argvDFB; 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: // update internal arg[cv] as DFB may have removed processed options:
this->argc = argc; this->argc = argc;
#if wxUSE_UNICODE
this->argv.Init(argc, argv); this->argv.Init(argc, argv);
#else
this->argv = argv;
#endif
if ( !wxIDirectFB::Get() ) if ( !wxIDirectFB::Get() )
return false; return false;

View file

@ -961,21 +961,7 @@ static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id,
switch ( DFB_KEY_TYPE(key_symbol) ) switch ( DFB_KEY_TYPE(key_symbol) )
{ {
case DIKT_UNICODE: case DIKT_UNICODE:
#if wxUSE_UNICODE
return key_symbol; 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: default:
return GetTranslatedKeyCode(key_id); return GetTranslatedKeyCode(key_id);
@ -1002,9 +988,7 @@ void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent& event_)
event.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e)); event.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e));
event.m_rawCode = e.key_code; event.m_rawCode = e.key_code;
event.m_keyCode = GetTranslatedKeyCode(e.key_id); event.m_keyCode = GetTranslatedKeyCode(e.key_id);
#if wxUSE_UNICODE
event.m_uniChar = e.key_symbol; event.m_uniChar = e.key_symbol;
#endif
event.m_shiftDown = ( e.modifiers & DIMM_SHIFT ) != 0; event.m_shiftDown = ( e.modifiers & DIMM_SHIFT ) != 0;
event.m_controlDown = ( e.modifiers & DIMM_CONTROL ) != 0; event.m_controlDown = ( e.modifiers & DIMM_CONTROL ) != 0;
event.m_altDown = ( e.modifiers & DIMM_ALT ) != 0; event.m_altDown = ( e.modifiers & DIMM_ALT ) != 0;

View file

@ -96,11 +96,9 @@ wxString wxAboutDialogInfo::GetCopyrightToDisplay() const
{ {
wxString ret = m_copyright; wxString ret = m_copyright;
#if wxUSE_UNICODE
const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9"); const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9");
ret.Replace("(c)", copyrightSign); ret.Replace("(c)", copyrightSign);
ret.Replace("(C)", copyrightSign); ret.Replace("(C)", copyrightSign);
#endif // wxUSE_UNICODE
return ret; return ret;
} }

View file

@ -400,13 +400,8 @@ bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event)
if ((ctrl || alt) && !(ctrl && alt)) if ((ctrl || alt) && !(ctrl && alt))
return false; return false;
#if wxUSE_UNICODE
if ( static_cast<int>(event.GetUnicodeKey()) == WXK_NONE ) if ( static_cast<int>(event.GetUnicodeKey()) == WXK_NONE )
return false; return false;
#else
if ( event.GetKeyCode() > WXK_START )
return false;
#endif
return true; return true;
} }
@ -584,12 +579,10 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
bool isPrintable; bool isPrintable;
#if wxUSE_UNICODE
ch = event.GetUnicodeKey(); ch = event.GetUnicodeKey();
if ( ch != WXK_NONE ) if ( ch != WXK_NONE )
isPrintable = true; isPrintable = true;
else else
#endif // wxUSE_UNICODE
{ {
ch = event.GetKeyCode(); ch = event.GetKeyCode();
isPrintable = ch >= WXK_SPACE && ch < WXK_START; isPrintable = ch >= WXK_SPACE && ch < WXK_START;

View file

@ -303,10 +303,6 @@ wxHtmlCell* wxHtmlListBox::CreateCellForItem(size_t n) const
self->m_htmlParser = new wxHtmlWinParser(self); self->m_htmlParser = new wxHtmlWinParser(self);
m_htmlParser->SetDC(new wxClientDC(self)); m_htmlParser->SetDC(new wxClientDC(self));
m_htmlParser->SetFS(&self->m_filesystem); 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: // use system's default GUI font by default:
m_htmlParser->SetStandardFonts(); m_htmlParser->SetStandardFonts();
} }

View file

@ -497,11 +497,8 @@ wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxString& szTi
wxDefaultSize, wxDefaultSize,
wxTE_MULTILINE | wxTE_MULTILINE |
wxHSCROLL | wxHSCROLL |
// needed for Win32 to avoid 65Kb limit but it doesn't work well // needed for Win32 to avoid 65Kb limit
// when using RichEdit 2.0 which we always do in the Unicode build
#if !wxUSE_UNICODE
wxTE_RICH | wxTE_RICH |
#endif // !wxUSE_UNICODE
wxTE_READONLY); wxTE_READONLY);
#if wxUSE_MENUS #if wxUSE_MENUS

View file

@ -426,11 +426,7 @@ void wxVListBoxComboPopup::OnComboCharEvent( wxKeyEvent& event )
{ {
// unlike in OnComboKeyEvent, wxEVT_CHAR contains meaningful // unlike in OnComboKeyEvent, wxEVT_CHAR contains meaningful
// printable character information, so pass it // printable character information, so pass it
#if wxUSE_UNICODE
const wxChar charcode = event.GetUnicodeKey(); const wxChar charcode = event.GetUnicodeKey();
#else
const wxChar charcode = (wxChar)event.GetKeyCode();
#endif
if ( !HandleKey(event.GetKeyCode(), true, charcode) ) if ( !HandleKey(event.GetKeyCode(), true, charcode) )
event.Skip(); event.Skip();
@ -508,11 +504,7 @@ void wxVListBoxComboPopup::OnChar(wxKeyEvent& event)
{ {
// Process partial completion key codes here, but not the arrow keys as // Process partial completion key codes here, but not the arrow keys as
// the base class will do that for us // the base class will do that for us
#if wxUSE_UNICODE
const wxChar charcode = event.GetUnicodeKey(); const wxChar charcode = event.GetUnicodeKey();
#else
const wxChar charcode = (wxChar)event.GetKeyCode();
#endif
if ( wxIsprint(charcode) ) if ( wxIsprint(charcode) )
{ {
OnComboCharEvent(event); OnComboCharEvent(event);

View file

@ -52,19 +52,12 @@ public:
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{ {
#if wxUSE_UNICODE
// notice that there is no need to copy the string pointer here // notice that there is no need to copy the string pointer here
// because this class is used only as a temporary and during its // because this class is used only as a temporary and during its
// existence the pointer persists in wxString which uses it either // existence the pointer persists in wxString which uses it either
// for internal representation (in wxUSE_UNICODE_UTF8 case) or as // for internal representation (in wxUSE_UNICODE_UTF8 case) or as
// cached m_convertedToChar (in wxUSE_UNICODE_WCHAR case) // cached m_convertedToChar (in wxUSE_UNICODE_WCHAR case)
m_strings[n] = wxGTK_CONV_SYS(a[n]); 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 // array must be null-terminated
@ -75,11 +68,6 @@ public:
~GtkArray() ~GtkArray()
{ {
#if !wxUSE_UNICODE
for ( size_t n = 0; n < m_count; n++ )
free(const_cast<gchar *>(m_strings[n]));
#endif
delete [] m_strings; delete [] m_strings;
} }

View file

@ -474,7 +474,6 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
bool init_result; bool init_result;
#if wxUSE_UNICODE
int i; int i;
// gtk_init() wants UTF-8, not wchar_t, so convert // gtk_init() wants UTF-8, not wchar_t, so convert
@ -530,19 +529,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
} }
delete [] argvGTK; 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: // update internal arg[cv] as GTK+ may have removed processed options:
this->argc = argc_; this->argc = argc_;
#if wxUSE_UNICODE
this->argv.Init(argc_, argv_); this->argv.Init(argc_, argv_);
#else
this->argv = argv_;
#endif
if ( !init_result ) if ( !init_result )
{ {

Some files were not shown because too many files have changed in this diff Show more