Remove wxUSE_WCHAR_T checks.

wxWidgets requires wchar_t for some time now; wx/chartype.h has a check
to fail complation without it. Simplify code by removing now-dead code
for the !wxUSE_WCHAR_T case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63991 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-04-16 10:43:18 +00:00
parent 605ff820f5
commit 8d94819c43
28 changed files with 80 additions and 278 deletions

View File

@@ -359,7 +359,6 @@ public:
wxCharBuffer(const wxCStrData& cstr); wxCharBuffer(const wxCStrData& cstr);
}; };
#if wxUSE_WCHAR_T
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer<wchar_t> ) WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer<wchar_t> )
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> ) WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> )
@@ -379,7 +378,6 @@ public:
wxWCharBuffer(const wxCStrData& cstr); wxWCharBuffer(const wxCStrData& cstr);
}; };
#endif // wxUSE_WCHAR_T
// wxCharTypeBuffer<T> implicitly convertible to T* // wxCharTypeBuffer<T> implicitly convertible to T*
template <typename T> template <typename T>

View File

@@ -59,7 +59,6 @@
#endif #endif
#endif #endif
#if wxUSE_WCHAR_T
#ifdef HAVE_WCHAR_H #ifdef HAVE_WCHAR_H
/* the current (as of Nov 2002) version of cygwin has a bug in its */ /* the current (as of Nov 2002) version of cygwin has a bug in its */
/* wchar.h -- there is no extern "C" around the declarations in it */ /* wchar.h -- there is no extern "C" around the declarations in it */
@@ -89,7 +88,6 @@
#ifdef HAVE_WIDEC_H #ifdef HAVE_WIDEC_H
#include <widec.h> #include <widec.h>
#endif #endif
#endif /* wxUSE_WCHAR_T */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */ /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */

View File

@@ -1313,15 +1313,6 @@
# endif # endif
#endif /* wxUSE_TEXTFILE */ #endif /* wxUSE_TEXTFILE */
#if wxUSE_XML && !wxUSE_WCHAR_T
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_XML requires wxUSE_WCHAR_T"
# else
# undef wxUSE_XML
# define wxUSE_XML 0
# endif
#endif /* wxUSE_XML */
#if !wxUSE_DYNLIB_CLASS #if !wxUSE_DYNLIB_CLASS
# if wxUSE_DYNAMIC_LOADER # if wxUSE_DYNAMIC_LOADER
# ifdef wxABORT_ON_CONFIG_ERROR # ifdef wxABORT_ON_CONFIG_ERROR

View File

@@ -226,10 +226,8 @@ public:
// template Read() would be used // template Read() would be used
wxString Read(const wxString& key, const char* defVal) const wxString Read(const wxString& key, const char* defVal) const
{ return Read(key, wxString(defVal)); } { return Read(key, wxString(defVal)); }
#if wxUSE_WCHAR_T
wxString Read(const wxString& key, const wchar_t* defVal) const wxString Read(const wxString& key, const wchar_t* defVal) const
{ return Read(key, wxString(defVal)); } { return Read(key, wxString(defVal)); }
#endif
long ReadLong(const wxString& key, long defVal) const long ReadLong(const wxString& key, long defVal) const
{ long l; (void)Read(key, &l, defVal); return l; } { long l; (void)Read(key, &l, defVal); return l; }
@@ -273,10 +271,8 @@ public:
{ return Write(key, wxString(value)); } { return Write(key, wxString(value)); }
bool Write(const wxString& key, const unsigned char *value) bool Write(const wxString& key, const unsigned char *value)
{ return Write(key, wxString(value)); } { return Write(key, wxString(value)); }
#if wxUSE_WCHAR_T
bool Write(const wxString& key, const wchar_t *value) bool Write(const wxString& key, const wchar_t *value)
{ return Write(key, wxString(value)); } { return Write(key, wxString(value)); }
#endif
// we also have to provide specializations for other types which we want to // we also have to provide specializations for other types which we want to

View File

@@ -14,8 +14,6 @@
#include "wx/strconv.h" #include "wx/strconv.h"
#include "wx/fontenc.h" #include "wx/fontenc.h"
#if wxUSE_WCHAR_T
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxConvAuto: uses BOM to automatically detect input encoding // wxConvAuto: uses BOM to automatically detect input encoding
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -144,7 +142,5 @@ private:
wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto); wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto);
}; };
#endif // wxUSE_WCHAR_T
#endif // _WX_CONVAUTO_H_ #endif // _WX_CONVAUTO_H_

View File

@@ -908,7 +908,7 @@ typedef wxUint16 wxWord;
#if defined(__MACH__) && !defined(SIZEOF_WCHAR_T) #if defined(__MACH__) && !defined(SIZEOF_WCHAR_T)
#define SIZEOF_WCHAR_T 4 #define SIZEOF_WCHAR_T 4
#endif #endif
#if wxUSE_WCHAR_T && !defined(SIZEOF_WCHAR_T) #if !defined(SIZEOF_WCHAR_T)
/* also assume that sizeof(wchar_t) == 2 (under Unix the most */ /* also assume that sizeof(wchar_t) == 2 (under Unix the most */
/* common case is 4 but there configure would have defined */ /* common case is 4 but there configure would have defined */
/* SIZEOF_WCHAR_T for us) */ /* SIZEOF_WCHAR_T for us) */
@@ -917,10 +917,14 @@ typedef wxUint16 wxWord;
Wchar_tMustBeExactly2Bytes); Wchar_tMustBeExactly2Bytes);
#define SIZEOF_WCHAR_T 2 #define SIZEOF_WCHAR_T 2
#endif /* wxUSE_WCHAR_T */ #endif /* !defined(SIZEOF_WCHAR_T) */
#endif #endif
#endif /* Win/!Win */ #endif /* Win/!Win */
#ifndef SIZEOF_WCHAR_T
#error "SIZEOF_WCHAR_T must be defined, but isn't"
#endif
/* also define C99-like sized MIN/MAX constants */ /* also define C99-like sized MIN/MAX constants */
#define wxINT8_MIN CHAR_MIN #define wxINT8_MIN CHAR_MIN
#define wxINT8_MAX CHAR_MAX #define wxINT8_MAX CHAR_MAX
@@ -1248,14 +1252,14 @@ typedef double wxDouble;
/* Define wxChar16 and wxChar32 */ /* Define wxChar16 and wxChar32 */
#if wxUSE_WCHAR_T && (!defined(SIZEOF_WCHAR_T) || (SIZEOF_WCHAR_T == 2)) #if SIZEOF_WCHAR_T == 2
#define wxWCHAR_T_IS_WXCHAR16 #define wxWCHAR_T_IS_WXCHAR16
typedef wchar_t wxChar16; typedef wchar_t wxChar16;
#else #else
typedef wxUint16 wxChar16; typedef wxUint16 wxChar16;
#endif #endif
#if wxUSE_WCHAR_T && defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) #if SIZEOF_WCHAR_T == 4
#define wxWCHAR_T_IS_WXCHAR32 #define wxWCHAR_T_IS_WXCHAR32
typedef wchar_t wxChar32; typedef wchar_t wxChar32;
#else #else

View File

@@ -57,7 +57,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject
virtual ~wxEncodingConverter() { if (m_Table) delete[] m_Table; } virtual ~wxEncodingConverter() { if (m_Table) delete[] m_Table; }
// Initialize conversion. Both output or input encoding may // Initialize conversion. Both output or input encoding may
// be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. // be wxFONTENCODING_UNICODE.
// //
// All subsequent calls to Convert() will interpret it's argument // All subsequent calls to Convert() will interpret it's argument
// as a string in input_enc encoding and will output string in // as a string in input_enc encoding and will output string in
@@ -91,12 +91,11 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject
bool Convert(char* str) const { return Convert(str, str); } bool Convert(char* str) const { return Convert(str, str); }
wxString Convert(const wxString& input) const; wxString Convert(const wxString& input) const;
#if wxUSE_WCHAR_T
bool Convert(const char* input, wchar_t* output) const; bool Convert(const char* input, wchar_t* output) const;
bool Convert(const wchar_t* input, char* output) const; bool Convert(const wchar_t* input, char* output) const;
bool Convert(const wchar_t* input, wchar_t* output) const; bool Convert(const wchar_t* input, wchar_t* output) const;
bool Convert(wchar_t* str) const { return Convert(str, str); } bool Convert(wchar_t* str) const { return Convert(str, str); }
#endif
// Return equivalent(s) for given font that are used // Return equivalent(s) for given font that are used
// under given platform. wxPLATFORM_CURRENT means the plaform // under given platform. wxPLATFORM_CURRENT means the plaform
// this binary was compiled for // this binary was compiled for
@@ -144,12 +143,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject
} }
private: private:
#if wxUSE_WCHAR_T
wchar_t *m_Table; wchar_t *m_Table;
#else
char *m_Table;
#endif
bool m_UnicodeInput, m_UnicodeOutput; bool m_UnicodeInput, m_UnicodeOutput;
bool m_JustCopy; bool m_JustCopy;

View File

@@ -269,8 +269,12 @@ public:
virtual ~wxHtmlEntitiesParser(); virtual ~wxHtmlEntitiesParser();
// Sets encoding of output string. // Sets encoding of output string.
// Has no effect if wxUSE_WCHAR_T==0 or wxUSE_UNICODE==1 // Has no effect if wxUSE_UNICODE==1
#if wxUSE_UNICODE
void SetEncoding(wxFontEncoding WXUNUSED(encoding)) {}
#else
void SetEncoding(wxFontEncoding encoding); 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)
@@ -287,7 +291,7 @@ public:
#endif #endif
protected: protected:
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
wxMBConv *m_conv; wxMBConv *m_conv;
wxFontEncoding m_encoding; wxFontEncoding m_encoding;
#endif #endif

View File

@@ -64,13 +64,11 @@ public:
m_ptr.charName = str; m_ptr.charName = str;
m_flags = IsCharPtr; m_flags = IsCharPtr;
} }
#if wxUSE_WCHAR_T
wxPGPropArgCls( const wchar_t* str ) wxPGPropArgCls( const wchar_t* str )
{ {
m_ptr.wcharName = str; m_ptr.wcharName = str;
m_flags = IsWCharPtr; m_flags = IsWCharPtr;
} }
#endif
/** This constructor is required for NULL. */ /** This constructor is required for NULL. */
wxPGPropArgCls( int ) wxPGPropArgCls( int )
{ {
@@ -100,9 +98,7 @@ private:
{ {
wxPGProperty* property; wxPGProperty* property;
const char* charName; const char* charName;
#if wxUSE_WCHAR_T
const wchar_t* wcharName; const wchar_t* wcharName;
#endif
const wxString* stringName; const wxString* stringName;
} m_ptr; } m_ptr;
unsigned char m_flags; unsigned char m_flags;
@@ -1171,12 +1167,10 @@ public:
wxVariant v(value); wxVariant v(value);
SetPropVal( id, v ); SetPropVal( id, v );
} }
#if wxUSE_WCHAR_T
void SetPropertyValue( wxPGPropArg id, const wchar_t* value ) void SetPropertyValue( wxPGPropArg id, const wchar_t* value )
{ {
SetPropertyValueString( id, wxString(value) ); SetPropertyValueString( id, wxString(value) );
} }
#endif
void SetPropertyValue( wxPGPropArg id, const char* value ) void SetPropertyValue( wxPGPropArg id, const char* value )
{ {
SetPropertyValueString( id, wxString(value) ); SetPropertyValueString( id, wxString(value) );

View File

@@ -29,8 +29,6 @@
#include <stdlib.h> #include <stdlib.h>
#endif // ! __WXPALMOS5__ #endif // ! __WXPALMOS5__
#if wxUSE_WCHAR_T
class WXDLLIMPEXP_FWD_BASE wxString; class WXDLLIMPEXP_FWD_BASE wxString;
// the error value returned by wxMBConv methods // the error value returned by wxMBConv methods
@@ -643,33 +641,6 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
#define wxFNSTRINGCAST WXSTRINGCAST #define wxFNSTRINGCAST WXSTRINGCAST
#endif #endif
#else // !wxUSE_WCHAR_T
// ----------------------------------------------------------------------------
// stand-ins in absence of wchar_t
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxMBConv
{
public:
const char* cMB2WX(const char *psz) const { return psz; }
const char* cWX2MB(const char *psz) const { return psz; }
};
#define wxConvFile wxConvLocal
extern WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc,
wxConvLocal,
wxConvISO8859_1,
wxConvUTF8;
extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent;
#define wxFNCONV(name) name
#define wxFNSTRINGCAST WXSTRINGCAST
#endif
// wxUSE_WCHAR_T
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// macros for the most common conversions // macros for the most common conversions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -39,7 +39,6 @@ inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); }
/* multibyte to wide char conversion functions and macros */ /* multibyte to wide char conversion functions and macros */
#if wxUSE_WCHAR_T
/* multibyte<->widechar conversion */ /* multibyte<->widechar conversion */
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);
@@ -55,15 +54,6 @@ inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); }
#define wxWC2WX wxWC2MB #define wxWC2WX wxWC2MB
#define wxWX2WC wxMB2WC #define wxWX2WC wxMB2WC
#endif #endif
#else /* !wxUSE_UNICODE */
/* No wxUSE_WCHAR_T: we have to do something (JACS) */
#define wxMB2WC wxStrncpy
#define wxWC2MB wxStrncpy
#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,

View File

@@ -10,8 +10,7 @@
@class wxEncodingConverter @class wxEncodingConverter
This class is capable of converting strings between two 8-bit encodings/charsets. This class is capable of converting strings between two 8-bit encodings/charsets.
It can also convert from/to Unicode (but only if you compiled wxWidgets It can also convert from/to Unicode.
with @c wxUSE_WCHAR_T set to 1).
Only a limited subset of encodings is supported by wxEncodingConverter: Only a limited subset of encodings is supported by wxEncodingConverter:
@c wxFONTENCODING_ISO8859_1..15, @c wxFONTENCODING_CP1250..1257 and @c wxFONTENCODING_ISO8859_1..15, @c wxFONTENCODING_CP1250..1257 and
@@ -64,9 +63,6 @@ public:
considered a lossless operation. considered a lossless operation.
@note You must call Init() before using this method! @note You must call Init() before using this method!
@note wchar_t versions of the method are not available if wxWidgets was
compiled with @c wxUSE_WCHAR_T set to 0.
*/ */
bool Convert(const char* input, char* output) const; bool Convert(const char* input, char* output) const;
bool Convert(const wchar_t* input, wchar_t* output) const; bool Convert(const wchar_t* input, wchar_t* output) const;

View File

@@ -1922,7 +1922,6 @@ void FormMain::PopulateWithLibraryConfig ()
ADD_WX_LIB_CONF_GROUP(wxT("Unicode Support")) ADD_WX_LIB_CONF_GROUP(wxT("Unicode Support"))
ADD_WX_LIB_CONF( wxUSE_UNICODE ) ADD_WX_LIB_CONF( wxUSE_UNICODE )
ADD_WX_LIB_CONF( wxUSE_UNICODE_MSLU ) ADD_WX_LIB_CONF( wxUSE_UNICODE_MSLU )
ADD_WX_LIB_CONF( wxUSE_WCHAR_T )
ADD_WX_LIB_CONF_GROUP(wxT("Global Features")) ADD_WX_LIB_CONF_GROUP(wxT("Global Features"))
ADD_WX_LIB_CONF( wxUSE_EXCEPTIONS ) ADD_WX_LIB_CONF( wxUSE_EXCEPTIONS )

View File

@@ -23,8 +23,6 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_WCHAR_T
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h" #include "wx/wx.h"
#endif //WX_PRECOMP #endif //WX_PRECOMP
@@ -318,5 +316,3 @@ wxConvAuto::FromWChar(char *dst, size_t dstLen,
return m_conv->FromWChar(dst, dstLen, src, srcLen); return m_conv->FromWChar(dst, dstLen, src, srcLen);
} }
#endif // wxUSE_WCHAR_T

View File

@@ -25,12 +25,6 @@
#include "unictabl.inc" #include "unictabl.inc"
#endif #endif
#if wxUSE_WCHAR_T
typedef wchar_t tchar;
#else
typedef char tchar;
#endif
#ifdef __WXMAC__ #ifdef __WXMAC__
#include "wx/osx/core/cfstring.h" #include "wx/osx/core/cfstring.h"
#include <CoreFoundation/CFStringEncodingExt.h> #include <CoreFoundation/CFStringEncodingExt.h>
@@ -124,10 +118,6 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e
if (m_Table) {delete[] m_Table; m_Table = NULL;} if (m_Table) {delete[] m_Table; m_Table = NULL;}
#if !wxUSE_WCHAR_T
if (input_enc == wxFONTENCODING_UNICODE || output_enc == wxFONTENCODING_UNICODE) return false;
#endif
if (input_enc == output_enc) {m_JustCopy = true; return true;} if (input_enc == output_enc) {m_JustCopy = true; return true;}
m_UnicodeOutput = (output_enc == wxFONTENCODING_UNICODE); m_UnicodeOutput = (output_enc == wxFONTENCODING_UNICODE);
@@ -137,18 +127,18 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e
{ {
if ((out_tbl = GetEncTable(output_enc)) == NULL) return false; if ((out_tbl = GetEncTable(output_enc)) == NULL) return false;
m_Table = new tchar[65536]; m_Table = new wchar_t[65536];
for (i = 0; i < 128; i++) m_Table[i] = (tchar)i; // 7bit ASCII for (i = 0; i < 128; i++) m_Table[i] = (wchar_t)i; // 7bit ASCII
for (i = 128; i < 65536; i++) m_Table[i] = (tchar)0; for (i = 128; i < 65536; i++) m_Table[i] = (wchar_t)0;
if (method == wxCONVERT_SUBSTITUTE) if (method == wxCONVERT_SUBSTITUTE)
{ {
for (i = 0; i < encoding_unicode_fallback_count; i++) for (i = 0; i < encoding_unicode_fallback_count; i++)
m_Table[encoding_unicode_fallback[i].c] = (tchar) encoding_unicode_fallback[i].s; m_Table[encoding_unicode_fallback[i].c] = (wchar_t) encoding_unicode_fallback[i].s;
} }
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
m_Table[out_tbl[i]] = (tchar)(128 + i); m_Table[out_tbl[i]] = (wchar_t)(128 + i);
m_UnicodeInput = true; m_UnicodeInput = true;
} }
@@ -160,12 +150,12 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e
m_UnicodeInput = false; m_UnicodeInput = false;
m_Table = new tchar[256]; m_Table = new wchar_t[256];
for (i = 0; i < 128; i++) m_Table[i] = (tchar)i; // 7bit ASCII for (i = 0; i < 128; i++) m_Table[i] = (wchar_t)i; // 7bit ASCII
if (output_enc == wxFONTENCODING_UNICODE) if (output_enc == wxFONTENCODING_UNICODE)
{ {
for (i = 0; i < 128; i++) m_Table[128 + i] = (tchar)in_tbl[i]; for (i = 0; i < 128; i++) m_Table[128 + i] = (wchar_t)in_tbl[i];
return true; return true;
} }
else // output !Unicode else // output !Unicode
@@ -182,13 +172,9 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e
item = (CharsetItem*) bsearch(&key, encoding_unicode_fallback, item = (CharsetItem*) bsearch(&key, encoding_unicode_fallback,
encoding_unicode_fallback_count, sizeof(CharsetItem), CompareCharsetItems); encoding_unicode_fallback_count, sizeof(CharsetItem), CompareCharsetItems);
if (item) if (item)
m_Table[128 + i] = (tchar)item -> c; m_Table[128 + i] = (wchar_t)item -> c;
else else
#if wxUSE_WCHAR_T
m_Table[128 + i] = (wchar_t)(128 + i); m_Table[128 + i] = (wchar_t)(128 + i);
#else
m_Table[128 + i] = (char)(128 + i);
#endif
} }
delete[] rev; delete[] rev;
@@ -199,11 +185,11 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e
} }
#define REPLACEMENT_CHAR ((tchar)'?') #define REPLACEMENT_CHAR (L'?')
inline tchar GetTableValue(const tchar *table, tchar value, bool& repl) inline wchar_t GetTableValue(const wchar_t *table, wchar_t value, bool& repl)
{ {
tchar r = table[value]; wchar_t r = table[value];
if (r == 0 && value != 0) if (r == 0 && value != 0)
{ {
r = REPLACEMENT_CHAR; r = REPLACEMENT_CHAR;
@@ -240,8 +226,6 @@ bool wxEncodingConverter::Convert(const char* input, char* output) const
} }
#if wxUSE_WCHAR_T
bool wxEncodingConverter::Convert(const char* input, wchar_t* output) const bool wxEncodingConverter::Convert(const char* input, wchar_t* output) const
{ {
wxASSERT_MSG(m_UnicodeOutput, wxT("You cannot convert to 8-bit if output is const wchar_t*!")); wxASSERT_MSG(m_UnicodeOutput, wxT("You cannot convert to 8-bit if output is const wchar_t*!"));
@@ -331,8 +315,6 @@ bool wxEncodingConverter::Convert(const wchar_t* input, wchar_t* output) const
return !replaced; return !replaced;
} }
#endif // wxUSE_WCHAR_T
wxString wxEncodingConverter::Convert(const wxString& input) const wxString wxEncodingConverter::Convert(const wxString& input) const
{ {

View File

@@ -65,7 +65,6 @@
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
#include "wx/fontmap.h" #include "wx/fontmap.h"
#include "wx/encconv.h"
#include "wx/scopedptr.h" #include "wx/scopedptr.h"
#include "wx/apptrait.h" #include "wx/apptrait.h"
#include "wx/stdpaths.h" #include "wx/stdpaths.h"
@@ -1326,7 +1325,6 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
} }
#endif // wxUSE_UNICODE/wxUSE_FONTMAP #endif // wxUSE_UNICODE/wxUSE_FONTMAP
#if wxUSE_WCHAR_T
// conversion to use to convert catalog strings to the GUI encoding // conversion to use to convert catalog strings to the GUI encoding
wxMBConv *inputConv, wxMBConv *inputConv,
*inputConvPtr = NULL; // same as inputConv but safely deleteable *inputConvPtr = NULL; // same as inputConv but safely deleteable
@@ -1353,43 +1351,6 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
? NULL ? NULL
: new wxCSConv(msgIdCharset); : new wxCSConv(msgIdCharset);
#elif wxUSE_FONTMAP
wxASSERT_MSG( msgIdCharset.empty(),
wxS("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
wxEncodingConverter converter;
if ( convertEncoding )
{
wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(m_charset, false);
if ( enc == wxFONTENCODING_SYSTEM )
{
convertEncoding = false; // unknown encoding
}
else
{
targetEnc = wxLocale::GetSystemEncoding();
if (targetEnc == wxFONTENCODING_SYSTEM)
{
wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc);
if (a[0] == enc)
// no conversion needed, locale uses native encoding
convertEncoding = false;
if (a.GetCount() == 0)
// we don't know common equiv. under this platform
convertEncoding = false;
targetEnc = a[0];
}
}
if ( convertEncoding )
{
converter.Init(enc, targetEnc);
}
}
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
(void)convertEncoding; // get rid of warnings about unused parameter
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);
@@ -1400,11 +1361,9 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
#if wxUSE_UNICODE #if wxUSE_UNICODE
msgid = wxString(data, *inputConv); msgid = wxString(data, *inputConv);
#else // ASCII #else // ASCII
#if wxUSE_WCHAR_T
if ( inputConv && sourceConv ) if ( inputConv && sourceConv )
msgid = wxString(inputConv->cMB2WC(data), *sourceConv); msgid = wxString(inputConv->cMB2WC(data), *sourceConv);
else else
#endif
msgid = data; msgid = data;
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
@@ -1422,19 +1381,12 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
wxString msgstr; wxString msgstr;
#if wxUSE_UNICODE #if wxUSE_UNICODE
msgstr = wxString(str, *inputConv); msgstr = wxString(str, *inputConv);
#elif wxUSE_WCHAR_T #else
if ( inputConv ) if ( inputConv )
msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI); msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI);
else else
msgstr = str; msgstr = str;
#else // !wxUSE_WCHAR_T #endif // wxUSE_UNICODE/!wxUSE_UNICODE
#if wxUSE_FONTMAP
if ( bConvertEncoding )
msgstr = wxString(converter.Convert(str));
else
#endif
msgstr = str;
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
if ( !msgstr.empty() ) if ( !msgstr.empty() )
{ {
@@ -1452,10 +1404,8 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
} }
} }
#if wxUSE_WCHAR_T
delete sourceConv; delete sourceConv;
delete inputConvPtr; delete inputConvPtr;
#endif // wxUSE_WCHAR_T
return true; return true;
} }

View File

@@ -28,8 +28,6 @@
#include "wx/strconv.h" #include "wx/strconv.h"
#if wxUSE_WCHAR_T
#ifndef __WXWINCE__ #ifndef __WXWINCE__
#include <errno.h> #include <errno.h>
#endif #endif
@@ -3455,14 +3453,3 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName =
#else // !__DARWIN__ #else // !__DARWIN__
wxGet_wxConvLibcPtr(); wxGet_wxConvLibcPtr();
#endif // __DARWIN__/!__DARWIN__ #endif // __DARWIN__/!__DARWIN__
#else // !wxUSE_WCHAR_T
// FIXME-UTF8: remove this, wxUSE_WCHAR_T is required now
// stand-ins in absence of wchar_t
WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc,
wxConvISO8859_1,
wxConvLocal,
wxConvUTF8;
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T

View File

@@ -81,7 +81,6 @@ using namespace std ;
#include <xlocale.h> #include <xlocale.h>
#endif #endif
#if wxUSE_WCHAR_T
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)
{ {
// assume that we have mbsrtowcs() too if we have wcsrtombs() // assume that we have mbsrtowcs() too if we have wcsrtombs()
@@ -141,7 +140,6 @@ WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n)
return wxWcstombs(NULL, pwz, 0); return wxWcstombs(NULL, pwz, 0);
#endif #endif
} }
#endif // wxUSE_WCHAR_T
char* wxSetlocale(int category, const char *locale) char* wxSetlocale(int category, const char *locale)
{ {
@@ -735,7 +733,6 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt
} }
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
#if wxUSE_WCHAR_T
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ctype.h stuff (currently unused) // ctype.h stuff (currently unused)
@@ -953,8 +950,6 @@ wxCRT_StrftimeW(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm
} }
#endif // !wxCRT_StrftimeW #endif // !wxCRT_StrftimeW
#endif // wxUSE_WCHAR_T
#ifdef wxLongLong_t #ifdef wxLongLong_t
template<typename T> template<typename T>
static wxULongLong_t static wxULongLong_t
@@ -1109,7 +1104,7 @@ wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr, wchar_t** endptr, int base)
#endif // wxLongLong_t #endif // wxLongLong_t
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// functions which we may need even if !wxUSE_WCHAR_T // strtok() functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
template<typename T> template<typename T>

View File

@@ -967,13 +967,11 @@ static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id,
return key_symbol; return key_symbol;
else else
{ {
#if wxUSE_WCHAR_T
wchar_t chr = key_symbol; wchar_t chr = key_symbol;
wxCharBuffer buf(wxConvUI->cWC2MB(&chr, 1, NULL)); wxCharBuffer buf(wxConvUI->cWC2MB(&chr, 1, NULL));
if ( buf ) if ( buf )
return *buf; // may be 0 if failed return *buf; // may be 0 if failed
else else
#endif // wxUSE_WCHAR_T
return 0; return 0;
} }
#endif #endif

View File

@@ -531,7 +531,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
gtk_set_locale(); gtk_set_locale();
// We should have the wxUSE_WCHAR_T test on the _outside_
if (!wxOKlibc()) if (!wxOKlibc())
wxConvCurrent = &wxConvLocal; wxConvCurrent = &wxConvLocal;

View File

@@ -569,7 +569,6 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
// Now store the contents range // Now store the contents range
bookr->SetContentsRange(cont_start, m_contents.size()); bookr->SetContentsRange(cont_start, m_contents.size());
#if wxUSE_WCHAR_T
// MS HTML Help files [written by MS HTML Help Workshop] are broken // MS HTML Help files [written by MS HTML Help Workshop] are broken
// in that the data are iso-8859-1 (including HTML entities), but must // in that the data are iso-8859-1 (including HTML entities), but must
// be interpreted as being in language's windows charset. Correct the // be interpreted as being in language's windows charset. Correct the
@@ -597,11 +596,6 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
} }
#undef CORRECT_STR #undef CORRECT_STR
} }
#else
wxUnusedVar(IndexOld);
wxUnusedVar(ContentsOld);
wxASSERT_MSG(encoding == wxFONTENCODING_SYSTEM, wxT("Help files need charset conversion, but wxUSE_WCHAR_T is 0"));
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
m_bookRecords.Add(bookr); m_bookRecords.Add(bookr);
if (!m_index.empty()) if (!m_index.empty())

View File

@@ -433,7 +433,7 @@ void wxHtmlTagHandler::ParseInnerSource(const wxString& source)
IMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser,wxObject) IMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser,wxObject)
wxHtmlEntitiesParser::wxHtmlEntitiesParser() wxHtmlEntitiesParser::wxHtmlEntitiesParser()
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
: m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM) : m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM)
#endif #endif
{ {
@@ -441,14 +441,14 @@ wxHtmlEntitiesParser::wxHtmlEntitiesParser()
wxHtmlEntitiesParser::~wxHtmlEntitiesParser() wxHtmlEntitiesParser::~wxHtmlEntitiesParser()
{ {
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
delete m_conv; delete m_conv;
#endif #endif
} }
#if !wxUSE_UNICODE
void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
{ {
#if wxUSE_WCHAR_T && !wxUSE_UNICODE
if (encoding == m_encoding) if (encoding == m_encoding)
return; return;
@@ -459,10 +459,8 @@ void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
m_conv = NULL; m_conv = NULL;
else else
m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding)); m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding));
#else
(void) encoding;
#endif
} }
#endif // !wxUSE_UNICODE
wxString wxHtmlEntitiesParser::Parse(const wxString& input) const wxString wxHtmlEntitiesParser::Parse(const wxString& input) const
{ {
@@ -523,7 +521,6 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input) const
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const
{ {
#if wxUSE_WCHAR_T
char buf[2]; char buf[2];
wchar_t wbuf[2]; wchar_t wbuf[2];
wbuf[0] = (wchar_t)code; wbuf[0] = (wchar_t)code;
@@ -532,9 +529,6 @@ wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const
if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1)
return '?'; return '?';
return buf[0]; return buf[0];
#else
return (code < 256) ? (wxChar)code : '?';
#endif
} }
#endif #endif

View File

@@ -285,7 +285,7 @@ TAG_HANDLER_BEGIN(TITLE, "TITLE")
if (winIface) if (winIface)
{ {
wxString title(tag.GetBeginIter(), tag.GetEndIter1()); wxString title(tag.GetBeginIter(), tag.GetEndIter1());
#if !wxUSE_UNICODE && wxUSE_WCHAR_T #if !wxUSE_UNICODE
const wxFontEncoding enc = m_WParser->GetInputEncoding(); const wxFontEncoding enc = m_WParser->GetInputEncoding();
if ( enc != wxFONTENCODING_DEFAULT ) if ( enc != wxFONTENCODING_DEFAULT )
{ {

View File

@@ -1038,10 +1038,6 @@ wxTextCtrl::StreamIn(const wxString& value,
wxLogLastError(wxT("EM_STREAMIN")); wxLogLastError(wxT("EM_STREAMIN"));
} }
#if !wxUSE_WCHAR_T
free(wchBuf);
#endif // !wxUSE_WCHAR_T
return true; return true;
} }
@@ -1054,13 +1050,8 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
const int len = GetWindowTextLength(GetHwnd()); const int len = GetWindowTextLength(GetHwnd());
#if wxUSE_WCHAR_T
wxWCharBuffer wchBuf(len); wxWCharBuffer wchBuf(len);
wchar_t *wpc = wchBuf.data(); wchar_t *wpc = wchBuf.data();
#else
wchar_t *wchBuf = (wchar_t *)malloc((len + 1)*sizeof(wchar_t));
wchar_t *wpc = wchBuf;
#endif
wxStreamOutData data; wxStreamOutData data;
data.wpc = wpc; data.wpc = wpc;
@@ -1100,10 +1091,6 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
} }
} }
#if !wxUSE_WCHAR_T
free(wchBuf);
#endif // !wxUSE_WCHAR_T
return out; return out;
} }

View File

@@ -73,10 +73,8 @@ wxPGProperty* wxPGPropArgCls::GetPtr( wxPropertyGridInterface* iface ) const
return iface->GetPropertyByNameA(*m_ptr.stringName); return iface->GetPropertyByNameA(*m_ptr.stringName);
else if ( m_flags & IsCharPtr ) else if ( m_flags & IsCharPtr )
return iface->GetPropertyByNameA(m_ptr.charName); return iface->GetPropertyByNameA(m_ptr.charName);
#if wxUSE_WCHAR_T
else if ( m_flags & IsWCharPtr ) else if ( m_flags & IsWCharPtr )
return iface->GetPropertyByNameA(m_ptr.wcharName); return iface->GetPropertyByNameA(m_ptr.wcharName);
#endif
return NULL; return NULL;
} }

View File

@@ -459,7 +459,7 @@ void wx28HtmlTagHandler::ParseInnerSource(const wxString& source)
IMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject) IMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject)
wx28HtmlEntitiesParser::wx28HtmlEntitiesParser() wx28HtmlEntitiesParser::wx28HtmlEntitiesParser()
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
: m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM) : m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM)
#endif #endif
{ {
@@ -467,14 +467,14 @@ wx28HtmlEntitiesParser::wx28HtmlEntitiesParser()
wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser() wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser()
{ {
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
delete m_conv; delete m_conv;
#endif #endif
} }
void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
{ {
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
if (encoding == m_encoding) if (encoding == m_encoding)
return; return;
@@ -552,7 +552,6 @@ extern "C" int LINKAGEMODE wx28HtmlEntityCompare(const void *key, const void *it
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code) wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code)
{ {
#if wxUSE_WCHAR_T
char buf[2]; char buf[2];
wchar_t wbuf[2]; wchar_t wbuf[2];
wbuf[0] = (wchar_t)code; wbuf[0] = (wchar_t)code;
@@ -561,9 +560,6 @@ wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code)
if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1)
return '?'; return '?';
return buf[0]; return buf[0];
#else
return (code < 256) ? (wxChar)code : '?';
#endif
} }
#endif #endif

View File

@@ -250,7 +250,7 @@ public:
virtual ~wx28HtmlEntitiesParser(); virtual ~wx28HtmlEntitiesParser();
// Sets encoding of output string. // Sets encoding of output string.
// Has no effect if wxUSE_WCHAR_T==0 or wxUSE_UNICODE==1 // Has no effect if wxUSE_UNICODE==1
void SetEncoding(wxFontEncoding encoding); void SetEncoding(wxFontEncoding encoding);
// Parses entities in input and replaces them with respective characters // Parses entities in input and replaces them with respective characters
@@ -268,7 +268,7 @@ public:
#endif #endif
protected: protected:
#if wxUSE_WCHAR_T && !wxUSE_UNICODE #if !wxUSE_UNICODE
wxMBConv *m_conv; wxMBConv *m_conv;
wxFontEncoding m_encoding; wxFontEncoding m_encoding;
#endif #endif

View File

@@ -17,8 +17,6 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_WCHAR_T
#include "wx/convauto.h" #include "wx/convauto.h"
#include "wx/mstream.h" #include "wx/mstream.h"
@@ -207,6 +205,3 @@ void ConvAutoTestCase::StreamUTF32BE()
"\0\0\x03\xB2", "\0\0\x03\xB2",
20, line1, line2); 20, line1, line2);
} }
#endif // wxUSE_WCHAR_T