#pragma implementation "string.h"
#endif
-#ifdef __WXPM__
-#define LINKAGECPP _Optlink
-#else
-#define LINKAGECPP
-#endif
-
/*
* About ref counting:
* 1) all empty strings use g_strEmpty, nRefs = -1 (set in Init())
{
wxStringData data;
wxChar dummy;
-} g_strEmpty = { {-1, 0, 0}, _T('\0') };
+} g_strEmpty = { {-1, 0, 0}, wxT('\0') };
// empty C style string: points to 'string data' byte of g_strEmpty
-extern const wxChar WXDLLEXPORT *g_szNul = &g_strEmpty.dummy;
+extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy;
// ----------------------------------------------------------------------------
// conditional compilation
}
}
-#else
+#else // ANSI
#if wxUSE_WCHAR_T
// from wide string
Init();
}
}
-#endif
+#endif // wxUSE_WCHAR_T
-#endif
+#endif // Unicode/ANSI
// ---------------------------------------------------------------------------
// memory allocation
pData->nDataLength = nLen;
pData->nAllocLength = nLen + EXTRA_ALLOC;
m_pchData = pData->data(); // data starts after wxStringData
- m_pchData[nLen] = _T('\0');
+ m_pchData[nLen] = wxT('\0');
}
// must be called before changing this string
pData->nDataLength = 0;
pData->nAllocLength = nLen;
m_pchData = pData->data(); // data starts after wxStringData
- m_pchData[0u] = _T('\0');
+ m_pchData[0u] = wxT('\0');
}
else if ( pData->IsShared() ) {
pData->Unlock(); // memory not freed because shared
AllocBeforeWrite(nSrcLen);
memcpy(m_pchData, pszSrcData, nSrcLen*sizeof(wxChar));
GetStringData()->nDataLength = nSrcLen;
- m_pchData[nSrcLen] = _T('\0');
+ m_pchData[nSrcLen] = wxT('\0');
}
}
// fast concatenation - all is done in our buffer
memcpy(m_pchData + nLen, pszSrcData, nSrcLen*sizeof(wxChar));
- m_pchData[nNewLen] = _T('\0'); // put terminating '\0'
+ m_pchData[nNewLen] = wxT('\0'); // put terminating '\0'
GetStringData()->nDataLength = nNewLen; // and fix the length
}
//else: the string to append was empty
wxString wxString::BeforeFirst(wxChar ch) const
{
wxString str;
- for ( const wxChar *pc = m_pchData; *pc != _T('\0') && *pc != ch; pc++ )
+ for ( const wxChar *pc = m_pchData; *pc != wxT('\0') && *pc != ch; pc++ )
str += *pc;
return str;
wxString strTemp;
const wxChar *pCurrent = m_pchData;
const wxChar *pSubstr;
- while ( *pCurrent != _T('\0') ) {
+ while ( *pCurrent != wxT('\0') ) {
pSubstr = wxStrstr(pCurrent, szOld);
if ( pSubstr == NULL ) {
// strTemp is unused if no replacements were made, so avoid the copy
psz--;
// truncate at trailing space start
- *++psz = _T('\0');
+ *++psz = wxT('\0');
GetStringData()->nDataLength = psz - m_pchData;
}
else
if ( uiLen < Len() ) {
CopyBeforeWrite();
- *(m_pchData + uiLen) = _T('\0');
+ *(m_pchData + uiLen) = wxT('\0');
GetStringData()->nDataLength = uiLen;
}
//else: nothing to do, string is already short enough
wxString& wxString::operator<<(int i)
{
wxString res;
- res.Printf(_T("%d"), i);
+ res.Printf(wxT("%d"), i);
return (*this) << res;
}
wxString& wxString::operator<<(float f)
{
wxString res;
- res.Printf(_T("%f"), f);
+ res.Printf(wxT("%f"), f);
return (*this) << res;
}
wxString& wxString::operator<<(double d)
{
wxString res;
- res.Printf(_T("%g"), d);
+ res.Printf(wxT("%g"), d);
return (*this) << res;
}
Reinit();
for (size_t n = 0; pszFormat[n]; n++)
- if (pszFormat[n] == _T('%')) {
+ if (pszFormat[n] == wxT('%')) {
static char s_szFlags[256] = "%";
size_t flagofs = 1;
bool adj_left = FALSE, in_prec = FALSE,
do {
#define CHECK_PREC if (in_prec && !prec_dot) { s_szFlags[flagofs++] = '.'; prec_dot = TRUE; }
switch (pszFormat[++n]) {
- case _T('\0'):
+ case wxT('\0'):
done = TRUE;
break;
- case _T('%'):
- *this += _T('%');
+ case wxT('%'):
+ *this += wxT('%');
done = TRUE;
break;
- case _T('#'):
- case _T('0'):
- case _T(' '):
- case _T('+'):
- case _T('\''):
+ case wxT('#'):
+ case wxT('0'):
+ case wxT(' '):
+ case wxT('+'):
+ case wxT('\''):
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('-'):
+ case wxT('-'):
CHECK_PREC
adj_left = TRUE;
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('.'):
+ case wxT('.'):
CHECK_PREC
in_prec = TRUE;
prec_dot = FALSE;
max_width = 0;
// dot will be auto-added to s_szFlags if non-negative number follows
break;
- case _T('h'):
+ case wxT('h'):
ilen = -1;
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('l'):
+ case wxT('l'):
ilen = 1;
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('q'):
- case _T('L'):
+ case wxT('q'):
+ case wxT('L'):
ilen = 2;
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('Z'):
+ case wxT('Z'):
ilen = 3;
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
break;
- case _T('*'):
+ case wxT('*'):
{
int len = va_arg(argptr, int);
if (in_prec) {
flagofs += ::sprintf(s_szFlags+flagofs,"%d",len);
}
break;
- case _T('1'): case _T('2'): case _T('3'):
- case _T('4'): case _T('5'): case _T('6'):
- case _T('7'): case _T('8'): case _T('9'):
+ case wxT('1'): case wxT('2'): case wxT('3'):
+ case wxT('4'): case wxT('5'): case wxT('6'):
+ case wxT('7'): case wxT('8'): case wxT('9'):
{
int len = 0;
CHECK_PREC
- while ((pszFormat[n]>=_T('0')) && (pszFormat[n]<=_T('9'))) {
+ while ((pszFormat[n]>=wxT('0')) && (pszFormat[n]<=wxT('9'))) {
s_szFlags[flagofs++] = pszFormat[n];
- len = len*10 + (pszFormat[n] - _T('0'));
+ len = len*10 + (pszFormat[n] - wxT('0'));
n++;
}
if (in_prec) max_width = len;
n--; // the main loop pre-increments n again
}
break;
- case _T('d'):
- case _T('i'):
- case _T('o'):
- case _T('u'):
- case _T('x'):
- case _T('X'):
+ case wxT('d'):
+ case wxT('i'):
+ case wxT('o'):
+ case wxT('u'):
+ case wxT('x'):
+ case wxT('X'):
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
s_szFlags[flagofs] = '\0';
*this += wxString(s_szScratch);
done = TRUE;
break;
- case _T('e'):
- case _T('E'):
- case _T('f'):
- case _T('g'):
- case _T('G'):
+ case wxT('e'):
+ case wxT('E'):
+ case wxT('f'):
+ case wxT('g'):
+ case wxT('G'):
CHECK_PREC
s_szFlags[flagofs++] = pszFormat[n];
s_szFlags[flagofs] = '\0';
*this += wxString(s_szScratch);
done = TRUE;
break;
- case _T('p'):
+ case wxT('p'):
{
void *val = va_arg(argptr, void *);
CHECK_PREC
done = TRUE;
}
break;
- case _T('c'):
+ case wxT('c'):
{
wxChar val = va_arg(argptr, int);
// we don't need to honor padding here, do we?
done = TRUE;
}
break;
- case _T('s'):
+ case wxT('s'):
if (ilen == -1) {
// wx extension: we'll let %hs mean non-Unicode strings
char *val = va_arg(argptr, char *);
size_t len = wxSTRING_MAXLEN;
if (val) {
for (len = 0; val[len] && (len<max_width); len++);
- } else val = _T("(null)");
+ } else val = wxT("(null)");
wxString s(val, len);
#endif
if (s.Len() < min_width)
- s.Pad(min_width - s.Len(), _T(' '), adj_left);
+ s.Pad(min_width - s.Len(), wxT(' '), adj_left);
*this += s;
} else {
wxChar *val = va_arg(argptr, wxChar *);
size_t len = wxSTRING_MAXLEN;
if (val) {
for (len = 0; val[len] && (len<max_width); len++);
- } else val = _T("(null)");
+ } else val = wxT("(null)");
wxString s(val, len);
if (s.Len() < min_width)
- s.Pad(min_width - s.Len(), _T(' '), adj_left);
+ s.Pad(min_width - s.Len(), wxT(' '), adj_left);
*this += s;
}
done = TRUE;
break;
- case _T('n'):
+ case wxT('n'):
if (ilen == 0) {
int *val = va_arg(argptr, int *);
*val = Len();
s_szFlags[flagofs++] = pszFormat[n];
else {
// bad format
- *this += _T('%'); // just to pass the glibc tst-printf.c
+ *this += wxT('%'); // just to pass the glibc tst-printf.c
n--;
done = TRUE;
}
// ----------------------------------------------------------------------------
// misc other operations
// ----------------------------------------------------------------------------
+
+// returns TRUE if the string matches the pattern which may contain '*' and
+// '?' metacharacters (as usual, '?' matches any character and '*' any number
+// of them)
bool wxString::Matches(const wxChar *pszMask) const
{
// check char by char
const wxChar *pszTxt;
- for ( pszTxt = c_str(); *pszMask != _T('\0'); pszMask++, pszTxt++ ) {
+ for ( pszTxt = c_str(); *pszMask != wxT('\0'); pszMask++, pszTxt++ ) {
switch ( *pszMask ) {
- case _T('?'):
- if ( *pszTxt == _T('\0') )
+ case wxT('?'):
+ if ( *pszTxt == wxT('\0') )
return FALSE;
- pszTxt++;
- pszMask++;
+ // pszText and pszMask will be incremented in the loop statement
+
break;
- case _T('*'):
+ case wxT('*'):
{
// ignore special chars immediately following this one
- while ( *pszMask == _T('*') || *pszMask == _T('?') )
+ while ( *pszMask == wxT('*') || *pszMask == wxT('?') )
pszMask++;
// if there is nothing more, match
- if ( *pszMask == _T('\0') )
+ if ( *pszMask == wxT('\0') )
return TRUE;
// are there any other metacharacters in the mask?
size_t uiLenMask;
- const wxChar *pEndMask = wxStrpbrk(pszMask, _T("*?"));
+ const wxChar *pEndMask = wxStrpbrk(pszMask, wxT("*?"));
if ( pEndMask != NULL ) {
// we have to match the string between two metachars
}
// match only if nothing left
- return *pszTxt == _T('\0');
+ return *pszTxt == wxT('\0');
}
// Count the number of chars
qsort(m_pItems, m_nCount, sizeof(wxChar *), wxStringCompareFunction);
}
-// ============================================================================
-// MBConv
-// ============================================================================
-
-WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;
-#if !wxUSE_WCHAR_T
-WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile;
-#endif
-
-#if wxUSE_WCHAR_T
-
-// ----------------------------------------------------------------------------
-// standard libc conversion
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConv) wxConvLibc;
-
-size_t wxMBConv::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- return wxMB2WC(buf, psz, n);
-}
-
-size_t wxMBConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- return wxWC2MB(buf, psz, n);
-}
-
-// ----------------------------------------------------------------------------
-// standard file conversion
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvFile) wxConvFile;
-
-// just use the libc conversion for now
-size_t wxMBConvFile::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- return wxMB2WC(buf, psz, n);
-}
-
-size_t wxMBConvFile::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- return wxWC2MB(buf, psz, n);
-}
-
-// ----------------------------------------------------------------------------
-// standard gdk conversion
-// ----------------------------------------------------------------------------
-
-#ifdef __WXGTK12__
-WXDLLEXPORT_DATA(wxMBConvGdk) wxConvGdk;
-
-#include <gdk/gdk.h>
-
-size_t wxMBConvGdk::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- if (buf) {
- return gdk_mbstowcs((GdkWChar *)buf, psz, n);
- } else {
- GdkWChar *nbuf = new GdkWChar[n=strlen(psz)];
- size_t len = gdk_mbstowcs(nbuf, psz, n);
- delete [] nbuf;
- return len;
- }
-}
-
-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;
- if (buf) {
- if (len > n) len = n;
- memcpy(buf, psz, len);
- if (len < n) buf[len] = 0;
- }
- return len;
-}
-#endif // GTK > 1.0
-
-// ----------------------------------------------------------------------------
-// UTF-7
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvUTF7) wxConvUTF7;
-
-#if 0
-static char utf7_setD[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789'(),-./:?";
-static char utf7_setO[]="!\"#$%&*;<=>@[]^_`{|}";
-static char utf7_setB[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
-#endif
-
-// TODO: write actual implementations of UTF-7 here
-size_t wxMBConvUTF7::MB2WC(wchar_t * WXUNUSED(buf),
- const char * WXUNUSED(psz),
- size_t WXUNUSED(n)) const
-{
- return 0;
-}
-
-size_t wxMBConvUTF7::WC2MB(char * WXUNUSED(buf),
- const wchar_t * WXUNUSED(psz),
- size_t WXUNUSED(n)) const
-{
- return 0;
-}
-
-// ----------------------------------------------------------------------------
-// UTF-8
-// ----------------------------------------------------------------------------
-
-WXDLLEXPORT_DATA(wxMBConvUTF8) wxConvUTF8;
-
-static unsigned long utf8_max[]={0x7f,0x7ff,0xffff,0x1fffff,0x3ffffff,0x7fffffff,0xffffffff};
-
-size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- size_t len = 0;
-
- while (*psz && ((!buf) || (len<n))) {
- unsigned char cc=*psz++, fc=cc;
- unsigned cnt;
- for (cnt=0; fc&0x80; cnt++) fc<<=1;
- if (!cnt) {
- // plain ASCII char
- if (buf) *buf++=cc;
- len++;
- } else {
- cnt--;
- if (!cnt) {
- // invalid UTF-8 sequence
- return (size_t)-1;
- } else {
- unsigned ocnt=cnt-1;
- unsigned long res=cc&(0x3f>>cnt);
- while (cnt--) {
- cc = *psz++;
- if ((cc&0xC0)!=0x80) {
- // invalid UTF-8 sequence
- return (size_t)-1;
- }
- res=(res<<6)|(cc&0x3f);
- }
- if (res<=utf8_max[ocnt]) {
- // illegal UTF-8 encoding
- return (size_t)-1;
- }
- if (buf) *buf++=res;
- len++;
- }
- }
- }
- if (buf && (len<n)) *buf = 0;
- return len;
-}
-
-size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- size_t len = 0;
-
- while (*psz && ((!buf) || (len<n))) {
- unsigned long cc=(*psz++)&0x7fffffff;
- unsigned cnt;
- for (cnt=0; cc>utf8_max[cnt]; cnt++);
- if (!cnt) {
- // plain ASCII char
- if (buf) *buf++=cc;
- len++;
- } else {
- len+=cnt+1;
- if (buf) {
- *buf++=(-128>>cnt)|((cc>>(cnt*6))&(0x3f>>cnt));
- while (cnt--)
- *buf++=0x80|((cc>>(cnt*6))&0x3f);
- }
- }
- }
- if (buf && (len<n)) *buf = 0;
- return len;
-}
-
-// ----------------------------------------------------------------------------
-// specified character set
-// ----------------------------------------------------------------------------
-
-class wxCharacterSet
-{
-public:
- wxArrayString names;
- wchar_t *data;
-};
-
-#ifndef WX_PRECOMP
- #include "wx/dynarray.h"
- #include "wx/filefn.h"
- #include "wx/textfile.h"
- #include "wx/tokenzr.h"
- #include "wx/utils.h"
-#endif
-
-WX_DECLARE_OBJARRAY(wxCharacterSet, wxCSArray);
-#include "wx/arrimpl.cpp"
-WX_DEFINE_OBJARRAY(wxCSArray);
-
-static wxCSArray wxCharsets;
-
-static void wxLoadCharacterSets(void)
-{
- static bool already_loaded = FALSE;
-
- if (already_loaded) return;
-
- already_loaded = TRUE;
-#if defined(__UNIX__) && wxUSE_TEXTFILE
- // search through files in /usr/share/i18n/charmaps
- wxString fname;
- for (fname = ::wxFindFirstFile(_T("/usr/share/i18n/charmaps/*"));
- !fname.IsEmpty();
- fname = ::wxFindNextFile()) {
- wxTextFile cmap(fname);
- if (cmap.Open()) {
- wxCharacterSet *cset = new wxCharacterSet;
- wxString comchar,escchar;
- bool in_charset = FALSE;
-
- // wxFprintf(stderr,_T("Loaded: %s\n"),fname.c_str());
-
- wxString line;
- for (line = cmap.GetFirstLine();
- !cmap.Eof();
- line = cmap.GetNextLine()) {
- // wxFprintf(stderr,_T("line contents: %s\n"),line.c_str());
- wxStringTokenizer token(line);
- wxString cmd = token.GetNextToken();
- if (cmd == comchar) {
- if (token.GetNextToken() == _T("alias"))
- cset->names.Add(token.GetNextToken());
- }
- else if (cmd == _T("<code_set_name>"))
- cset->names.Add(token.GetNextToken());
- else if (cmd == _T("<comment_char>"))
- comchar = token.GetNextToken();
- else if (cmd == _T("<escape_char>"))
- escchar = token.GetNextToken();
- else if (cmd == _T("<mb_cur_min>")) {
- delete cset;
- cset = (wxCharacterSet *) NULL;
- break; // we don't support multibyte charsets ourselves (yet)
- }
- else if (cmd == _T("CHARMAP")) {
- cset->data = (wchar_t *)calloc(256, sizeof(wchar_t));
- in_charset = TRUE;
- }
- else if (cmd == _T("END")) {
- if (token.GetNextToken() == _T("CHARMAP"))
- in_charset = FALSE;
- }
- else if (in_charset) {
- // format: <NUL> /x00 <U0000> NULL (NUL)
- // <A> /x41 <U0041> LATIN CAPITAL LETTER A
- wxString hex = token.GetNextToken();
- // skip whitespace (why doesn't wxStringTokenizer do this?)
- while (wxIsEmpty(hex) && token.HasMoreTokens()) hex = token.GetNextToken();
- wxString uni = token.GetNextToken();
- // skip whitespace again
- while (wxIsEmpty(uni) && token.HasMoreTokens()) uni = token.GetNextToken();
- if ((hex.Len() > 2) && (wxString(hex.GetChar(0)) == escchar) && (hex.GetChar(1) == _T('x')) &&
- (uni.Left(2) == _T("<U"))) {
- hex.MakeUpper(); uni.MakeUpper();
- int pos = ::wxHexToDec(hex.Mid(2,2));
- if (pos>=0) {
- unsigned long uni1 = ::wxHexToDec(uni.Mid(2,2));
- unsigned long uni2 = ::wxHexToDec(uni.Mid(4,2));
- cset->data[pos] = (uni1 << 16) | uni2;
- // wxFprintf(stderr,_T("char %02x mapped to %04x (%c)\n"),pos,cset->data[pos],cset->data[pos]);
- }
- }
- }
- }
- if (cset) {
- cset->names.Shrink();
- wxCharsets.Add(cset);
- }
- }
- }
-#endif
- wxCharsets.Shrink();
-}
-
-static wxCharacterSet *wxFindCharacterSet(const wxChar *charset)
-{
- if (!charset) return (wxCharacterSet *)NULL;
- wxLoadCharacterSets();
- for (size_t n=0; n<wxCharsets.GetCount(); n++)
- if (wxCharsets[n].names.Index(charset) != wxNOT_FOUND)
- return &(wxCharsets[n]);
- return (wxCharacterSet *)NULL;
-}
-
-WXDLLEXPORT_DATA(wxCSConv) wxConvLocal((const wxChar *)NULL);
-
-wxCSConv::wxCSConv(const wxChar *charset)
-{
- m_name = (wxChar *) NULL;
- m_cset = (wxCharacterSet *) NULL;
- m_deferred = TRUE;
- SetName(charset);
-}
-
-wxCSConv::~wxCSConv()
-{
- if (m_name) free(m_name);
-}
-
-void wxCSConv::SetName(const wxChar *charset)
-{
- if (charset) {
-#ifdef __UNIX__
- // first, convert the character set name to standard form
- wxString codeset;
- if (wxString(charset,3).CmpNoCase(_T("ISO")) == 0) {
- // make sure it's represented in the standard form: ISO_8859-1
- codeset = _T("ISO_");
- charset += 3;
- if ((*charset == _T('-')) || (*charset == _T('_'))) charset++;
- if (wxStrlen(charset)>4) {
- if (wxString(charset,4) == _T("8859")) {
- codeset << _T("8859-");
- if (*charset == _T('-')) charset++;
- }
- }
- }
- codeset << charset;
- codeset.MakeUpper();
- m_name = wxStrdup(codeset.c_str());
- m_deferred = TRUE;
-#endif
- }
-}
-
-void wxCSConv::LoadNow()
-{
-// wxPrintf(_T("Conversion request\n"));
- if (m_deferred) {
- if (!m_name) {
-#ifdef __UNIX__
- wxChar *lang = wxGetenv(_T("LANG"));
- wxChar *dot = lang ? wxStrchr(lang, _T('.')) : (wxChar *)NULL;
- if (dot) SetName(dot+1);
-#endif
- }
- m_cset = wxFindCharacterSet(m_name);
- m_deferred = FALSE;
- }
-}
-
-size_t wxCSConv::MB2WC(wchar_t *buf, const char *psz, size_t n) const
-{
- ((wxCSConv *)this)->LoadNow(); // discard constness
- if (buf) {
- if (m_cset) {
- for (size_t c=0; c<n; c++)
- buf[c] = m_cset->data[(unsigned char)(psz[c])];
- } else {
- // latin-1 (direct)
- for (size_t c=0; c<n; c++)
- buf[c] = (unsigned char)(psz[c]);
- }
- return n;
- }
- return strlen(psz);
-}
-
-size_t wxCSConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
-{
- ((wxCSConv *)this)->LoadNow(); // discard constness
- if (buf) {
- if (m_cset) {
- for (size_t c=0; c<n; c++) {
- size_t n;
- for (n=0; (n<256) && (m_cset->data[n] != psz[c]); n++);
- buf[c] = (n>0xff) ? '?' : n;
- }
- } else {
- // latin-1 (direct)
- for (size_t c=0; c<n; c++)
- buf[c] = (psz[c]>0xff) ? '?' : psz[c];
- }
- return n;
- }
- return wcslen(psz);
-}
-
-#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
-