X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eea4f86a0c4aab97216a6ce72cbaacacc840247f..ea804aadf91c963d97a56e152d8372c9e689affe:/src/common/string.cpp?ds=inline diff --git a/src/common/string.cpp b/src/common/string.cpp index a7d9a36ede..db8db9a004 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -274,6 +274,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) #else +#if wxUSE_WCHAR_T // from wide string wxString::wxString(const wchar_t *pwz) { @@ -289,6 +290,7 @@ wxString::wxString(const wchar_t *pwz) Init(); } } +#endif #endif @@ -495,12 +497,14 @@ wxString& wxString::operator=(const unsigned char* psz) return *this; } +#if wxUSE_WCHAR_T wxString& wxString::operator=(const wchar_t *pwz) { wxString str(pwz); *this = str; return *this; } +#endif #endif @@ -1164,7 +1168,7 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) char *val = va_arg(argptr, char *); #if wxUSE_UNICODE // ASCII->Unicode constructor handles max_width right - wxString s(val, wxConv_libc, max_width); + wxString s(val, wxConvLibc, max_width); #else size_t len = wxSTRING_MAXLEN; if (val) { @@ -1801,14 +1805,18 @@ void wxArrayString::DoSort() // MBConv // ============================================================================ +WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; +#if !wxUSE_WCHAR_T +WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile; +#endif + #if wxUSE_WCHAR_T -WXDLLEXPORT_DATA(wxMBConv *) wxConv_current = &wxConv_libc; // ---------------------------------------------------------------------------- // standard libc conversion // ---------------------------------------------------------------------------- -WXDLLEXPORT_DATA(wxMBConv) wxConv_libc; +WXDLLEXPORT_DATA(wxMBConv) wxConvLibc; size_t wxMBConv::MB2WC(wchar_t *buf, const char *psz, size_t n) const { @@ -1824,15 +1832,15 @@ size_t wxMBConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const // standard file conversion // ---------------------------------------------------------------------------- -WXDLLEXPORT_DATA(wxMBConv_file) wxConv_file; +WXDLLEXPORT_DATA(wxMBConvFile) wxConvFile; // just use the libc conversion for now -size_t wxMBConv_file::MB2WC(wchar_t *buf, const char *psz, size_t n) const +size_t wxMBConvFile::MB2WC(wchar_t *buf, const char *psz, size_t n) const { return wxMB2WC(buf, psz, n); } -size_t wxMBConv_file::WC2MB(char *buf, const wchar_t *psz, size_t n) const +size_t wxMBConvFile::WC2MB(char *buf, const wchar_t *psz, size_t n) const { return wxWC2MB(buf, psz, n); } @@ -1841,12 +1849,12 @@ size_t wxMBConv_file::WC2MB(char *buf, const wchar_t *psz, size_t n) const // standard gdk conversion // ---------------------------------------------------------------------------- -#if defined(__WXGTK__) && (GTK_MINOR_VERSION > 0) -WXDLLEXPORT_DATA(wxMBConv_gdk) wxConv_gdk; +#ifdef __WXGTK12__ +WXDLLEXPORT_DATA(wxMBConvGdk) wxConvGdk; #include -size_t wxMBConv_gdk::MB2WC(wchar_t *buf, const char *psz, size_t n) const +size_t wxMBConvGdk::MB2WC(wchar_t *buf, const char *psz, size_t n) const { if (buf) { return gdk_mbstowcs((GdkWChar *)buf, psz, n); @@ -1858,7 +1866,7 @@ size_t wxMBConv_gdk::MB2WC(wchar_t *buf, const char *psz, size_t n) const } } -size_t wxMBConv_gdk::WC2MB(char *buf, const wchar_t *psz, size_t n) const +size_t wxMBConvGdk::WC2MB(char *buf, const wchar_t *psz, size_t n) const { char *mbstr = gdk_wcstombs((GdkWChar *)psz); size_t len = mbstr ? strlen(mbstr) : 0; @@ -1875,7 +1883,7 @@ size_t wxMBConv_gdk::WC2MB(char *buf, const wchar_t *psz, size_t n) const // UTF-7 // ---------------------------------------------------------------------------- -WXDLLEXPORT_DATA(wxMBConv_UTF7) wxConv_UTF7; +WXDLLEXPORT_DATA(wxMBConvUTF7) wxConvUTF7; #if 0 static char utf7_setD[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -1888,12 +1896,16 @@ static char utf7_setB[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ" #endif // TODO: write actual implementations of UTF-7 here -size_t wxMBConv_UTF7::MB2WC(wchar_t *buf, const char *psz, size_t n) const +size_t wxMBConvUTF7::MB2WC(wchar_t * WXUNUSED(buf), + const char * WXUNUSED(psz), + size_t WXUNUSED(n)) const { return 0; } -size_t wxMBConv_UTF7::WC2MB(char *buf, const wchar_t *psz, size_t n) const +size_t wxMBConvUTF7::WC2MB(char * WXUNUSED(buf), + const wchar_t * WXUNUSED(psz), + size_t WXUNUSED(n)) const { return 0; } @@ -1902,11 +1914,11 @@ size_t wxMBConv_UTF7::WC2MB(char *buf, const wchar_t *psz, size_t n) const // UTF-8 // ---------------------------------------------------------------------------- -WXDLLEXPORT_DATA(wxMBConv_UTF8) wxConv_UTF8; +WXDLLEXPORT_DATA(wxMBConvUTF8) wxConvUTF8; static unsigned long utf8_max[]={0x7f,0x7ff,0xffff,0x1fffff,0x3ffffff,0x7fffffff,0xffffffff}; -size_t wxMBConv_UTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const +size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const { size_t len = 0; @@ -1947,7 +1959,7 @@ size_t wxMBConv_UTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const return len; } -size_t wxMBConv_UTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const +size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const { size_t len = 0; @@ -2026,12 +2038,8 @@ static void wxLoadCharacterSets(void) wxStringTokenizer token(line); wxString cmd = token.GetNextToken(); if (cmd == comchar) { - if (token.GetNextToken() == _T("alias")) { - wxStringTokenizer names(token.GetNextToken(),_T("/")); - wxString name; - while (!(name = names.GetNextToken()).IsEmpty()) - cset->names.Add(name); - } + if (token.GetNextToken() == _T("alias")) + cset->names.Add(token.GetNextToken()); } else if (cmd == _T("")) cset->names.Add(token.GetNextToken()); @@ -2095,7 +2103,7 @@ static wxCharacterSet *wxFindCharacterSet(const wxChar *charset) return (wxCharacterSet *)NULL; } -WXDLLEXPORT_DATA(wxCSConv) wxConv_local((const wxChar *)NULL); +WXDLLEXPORT_DATA(wxCSConv) wxConvLocal((const wxChar *)NULL); wxCSConv::wxCSConv(const wxChar *charset) { @@ -2190,3 +2198,27 @@ size_t wxCSConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const } #endif//wxUSE_WCHAR_T + +#if wxUSE_WCHAR_T +const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const + { + if (psz) { + size_t nLen = MB2WC((wchar_t *) NULL, psz, 0); + wxWCharBuffer buf(nLen); + MB2WC(WCSTRINGCAST buf, psz, nLen); + return buf; + } else return wxWCharBuffer((wchar_t *) NULL); + } + +const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *psz) const + { + if (psz) { + size_t nLen = WC2MB((char *) NULL, psz, 0); + wxCharBuffer buf(nLen); + WC2MB(MBSTRINGCAST buf, psz, nLen); + return buf; + } else return wxCharBuffer((char *) NULL); + } + +#endif//wxUSE_WCHAR_T +