]>
git.saurik.com Git - wxWidgets.git/blob - src/common/wxcrt.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/wxcrt.cpp
3 // Purpose: wxChar CRT wrappers implementation
5 // Modified by: Ron Lee, Francesco Montorsi
8 // Copyright: (c) wxWidgets copyright
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
13 // headers, declarations, constants
14 // ===========================================================================
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/wxchar.h"
25 #define _ISOC9X_SOURCE 1 // to get vsscanf()
26 #define _BSD_SOURCE 1 // to still get strdup()
36 #include "wx/msw/wince/time.h"
40 #include "wx/string.h"
42 #include "wx/utils.h" // for wxMin and wxMax
46 #if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
54 // there is no errno.h under CE apparently
55 #define wxSET_ERRNO(value)
59 #define wxSET_ERRNO(value) errno = value
62 #if defined(__MWERKS__) && __MSL__ >= 0x6000
68 size_t WXDLLEXPORT
wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
)
70 // assume that we have mbsrtowcs() too if we have wcsrtombs()
73 memset(&mbstate
, 0, sizeof(mbstate_t));
78 if (n
) *buf
= wxT('\0');
82 return mbsrtowcs(buf
, &psz
, n
, &mbstate
);
84 return wxMbstowcs(buf
, psz
, n
);
88 // note that we rely on common (and required by Unix98 but unfortunately not
89 // C99) extension which allows to call mbs(r)towcs() with NULL output pointer
90 // to just get the size of the needed buffer -- this is needed as otherwise
91 // we have no idea about how much space we need and if the CRT doesn't
92 // support it (the only currently known example being Metrowerks, see
93 // wx/wxchar.h) we don't use its mbstowcs() at all
95 return mbsrtowcs((wchar_t *) NULL
, &psz
, 0, &mbstate
);
97 return wxMbstowcs((wchar_t *) NULL
, psz
, 0);
101 size_t WXDLLEXPORT
wxWC2MB(char *buf
, const wchar_t *pwz
, size_t n
)
103 #ifdef HAVE_WCSRTOMBS
105 memset(&mbstate
, 0, sizeof(mbstate_t));
110 // glibc2.1 chokes on null input
114 #ifdef HAVE_WCSRTOMBS
115 return wcsrtombs(buf
, &pwz
, n
, &mbstate
);
117 return wxWcstombs(buf
, pwz
, n
);
121 #ifdef HAVE_WCSRTOMBS
122 return wcsrtombs((char *) NULL
, &pwz
, 0, &mbstate
);
124 return wxWcstombs((char *) NULL
, pwz
, 0);
127 #endif // wxUSE_WCHAR_T
129 bool WXDLLEXPORT
wxOKlibc()
131 #if wxUSE_WCHAR_T && defined(__UNIX__) && defined(__GLIBC__) && !defined(__WINE__)
132 // glibc 2.0 uses UTF-8 even when it shouldn't
134 if ((MB_CUR_MAX
== 2) &&
135 (wxMB2WC(&res
, "\xdd\xa5", 1) == 1) &&
137 // this is UTF-8 allright, check whether that's what we want
138 char *cur_locale
= setlocale(LC_CTYPE
, NULL
);
139 if ((strlen(cur_locale
) < 4) ||
140 (strcasecmp(cur_locale
+ strlen(cur_locale
) - 4, "utf8")) ||
141 (strcasecmp(cur_locale
+ strlen(cur_locale
) - 5, "utf-8"))) {
142 // nope, don't use libc conversion
150 char* wxSetlocale(int category
, const char *locale
)
152 char *rv
= setlocale(category
, locale
);
153 if ( locale
!= NULL
/* setting locale, not querying */ &&
154 rv
/* call was successful */ )
156 wxUpdateLocaleIsUtf8();
161 // ============================================================================
162 // printf() functions business
163 // ============================================================================
165 // special test mode: define all functions below even if we don't really need
166 // them to be able to test them
176 #define wxNEED_WPRINTF
178 int wxCRT_VfprintfW( FILE *stream
, const wchar_t *format
, va_list argptr
);
182 /* Digital Mars adds count to _stprintf (C99) so convert */
183 int wxCRT_SprintfW (wchar_t * __RESTRICT s
, const wchar_t * __RESTRICT format
, ... )
187 va_start( arglist
, format
);
188 int iLen
= swprintf ( s
, -1, format
, arglist
);
194 // ----------------------------------------------------------------------------
195 // implement the standard IO functions for wide char if libc doesn't have them
196 // ----------------------------------------------------------------------------
199 int wxCRT_FputsW(const wchar_t *ws
, FILE *stream
)
201 wxCharBuffer
buf(wxConvLibc
.cWC2MB(ws
));
205 // counting the number of wide characters written isn't worth the trouble,
206 // simply distinguish between ok and error
207 return wxCRT_FputsA(buf
, stream
) == -1 ? -1 : 0;
209 #endif // !wxCRT_FputsW
212 int wxCRT_PutsW(const wchar_t *ws
)
214 int rc
= wxCRT_FputsW(ws
, stdout
);
217 if ( wxCRT_FputsW(L
"\n", stdout
) == -1 )
225 #endif // !wxCRT_PutsW
228 int /* not wint_t */ wxCRT_FputcW(wchar_t wc
, FILE *stream
)
230 wchar_t ws
[2] = { wc
, L
'\0' };
232 return wxCRT_FputsW(ws
, stream
);
234 #endif // !wxCRT_FputcW
236 // NB: we only implement va_list functions here, the ones taking ... are
237 // defined below for wxNEED_PRINTF_CONVERSION case anyhow and we reuse
238 // the definitions there to avoid duplicating them here
239 #ifdef wxNEED_WPRINTF
241 // TODO: implement the scanf() functions
242 static int vwscanf(const wchar_t *format
, va_list argptr
)
244 wxFAIL_MSG( _T("TODO") );
249 static int vswscanf(const wchar_t *ws
, const wchar_t *format
, va_list argptr
)
251 // The best we can do without proper Unicode support in glibc is to
252 // convert the strings into MB representation and run ANSI version
253 // of the function. This doesn't work with %c and %s because of difference
254 // in size of char and wchar_t, though.
256 wxCHECK_MSG( wxStrstr(format
, _T("%s")) == NULL
, -1,
257 _T("incomplete vswscanf implementation doesn't allow %s") );
258 wxCHECK_MSG( wxStrstr(format
, _T("%c")) == NULL
, -1,
259 _T("incomplete vswscanf implementation doesn't allow %c") );
261 return vsscanf(wxConvLibc
.cWX2MB(ws
), wxConvLibc
.cWX2MB(format
), argptr
);
264 static int vfwscanf(FILE *stream
, const wchar_t *format
, va_list argptr
)
266 wxFAIL_MSG( _T("TODO") );
271 #define vswprintf wxCRT_VsnprintfW_
273 static int vfwprintf(FILE *stream
, const wchar_t *format
, va_list argptr
)
276 int rc
= s
.PrintfV(format
, argptr
);
280 // we can't do much better without Unicode support in libc...
281 if ( fprintf(stream
, "%s", (const char*)s
.mb_str() ) == -1 )
288 static int vwprintf(const wchar_t *format
, va_list argptr
)
290 return wxCRT_VfprintfW(stdout
, format
, argptr
);
293 #endif // wxNEED_WPRINTF
295 #ifdef wxNEED_PRINTF_CONVERSION
297 // ----------------------------------------------------------------------------
298 // wxFormatConverter: class doing the "%s" -> "%ls" conversion
299 // ----------------------------------------------------------------------------
302 Here are the gory details. We want to follow the Windows/MS conventions,
307 format specifier results in
308 -----------------------------------
314 format specifier results in
315 -----------------------------------
320 while on POSIX systems we have %C identical to %lc and %c always means char
321 (in any mode) while %lc always means wchar_t,
323 So to use native functions in order to get our semantics we must do the
324 following translations in Unicode mode (nothing to do in ANSI mode):
326 wxWidgets specifier POSIX specifier
327 ----------------------------------------
333 And, of course, the same should be done for %s as well.
336 class wxFormatConverter
339 wxFormatConverter(const wxChar
*format
);
341 // notice that we only translated the string if m_fmtOrig == NULL (as set
342 // by CopyAllBefore()), otherwise we should simply use the original format
343 operator const wxChar
*() const
344 { return m_fmtOrig
? m_fmtOrig
: m_fmt
.c_str(); }
347 // copy another character to the translated format: this function does the
348 // copy if we are translating but doesn't do anything at all if we don't,
349 // so we don't create the translated format string at all unless we really
350 // need to (i.e. InsertFmtChar() is called)
351 wxChar
CopyFmtChar(wxChar ch
)
355 // we're translating, do copy
360 // simply increase the count which should be copied by
361 // CopyAllBefore() later if needed
368 // insert an extra character
369 void InsertFmtChar(wxChar ch
)
373 // so far we haven't translated anything yet
382 wxASSERT_MSG( m_fmtOrig
&& m_fmt
.empty(), _T("logic error") );
384 m_fmt
= wxString(m_fmtOrig
, m_nCopied
);
386 // we won't need it any longer
390 static bool IsFlagChar(wxChar ch
)
392 return ch
== _T('-') || ch
== _T('+') ||
393 ch
== _T('0') || ch
== _T(' ') || ch
== _T('#');
396 void SkipDigits(const wxChar
**ptpc
)
398 while ( **ptpc
>= _T('0') && **ptpc
<= _T('9') )
399 CopyFmtChar(*(*ptpc
)++);
402 // the translated format
405 // the original format
406 const wxChar
*m_fmtOrig
;
408 // the number of characters already copied
412 wxFormatConverter::wxFormatConverter(const wxChar
*format
)
419 if ( CopyFmtChar(*format
++) == _T('%') )
422 while ( IsFlagChar(*format
) )
423 CopyFmtChar(*format
++);
425 // and possible width
426 if ( *format
== _T('*') )
427 CopyFmtChar(*format
++);
432 if ( *format
== _T('.') )
434 CopyFmtChar(*format
++);
435 if ( *format
== _T('*') )
436 CopyFmtChar(*format
++);
441 // next we can have a size modifier
457 // "ll" has a different meaning!
458 if ( format
[1] != _T('l') )
470 // and finally we should have the type
475 // %C and %hC -> %c and %lC -> %lc
477 CopyFmtChar(_T('l'));
479 InsertFmtChar(*format
++ == _T('C') ? _T('c') : _T('s'));
484 // %c -> %lc but %hc stays %hc and %lc is still %lc
485 if ( size
== Default
)
486 InsertFmtChar(_T('l'));
490 // nothing special to do
491 if ( size
!= Default
)
492 CopyFmtChar(*(format
- 1));
493 CopyFmtChar(*format
++);
499 #else // !wxNEED_PRINTF_CONVERSION
500 // no conversion necessary
501 #define wxFormatConverter(x) (x)
502 #endif // wxNEED_PRINTF_CONVERSION/!wxNEED_PRINTF_CONVERSION
505 // For testing the format converter
506 wxString
wxConvertFormat(const wxChar
*format
)
508 return wxString(wxFormatConverter(format
));
512 // ----------------------------------------------------------------------------
513 // wxPrintf(), wxScanf() and relatives
514 // ----------------------------------------------------------------------------
516 // FIXME-UTF8: do format conversion using (modified) wxFormatConverter in
517 // template wrappers, not here; note that it will needed to
518 // translate all forms of string specifiers to %(l)s for wxPrintf(),
519 // but it only should do what it did in 2.8 for wxScanf()!
521 #ifndef wxCRT_PrintfW
522 int wxCRT_PrintfW( const wchar_t *format
, ... )
525 va_start(argptr
, format
);
527 int ret
= vwprintf( wxFormatConverter(format
), argptr
);
535 #ifndef wxCRT_FprintfW
536 int wxCRT_FprintfW( FILE *stream
, const wchar_t *format
, ... )
539 va_start( argptr
, format
);
541 int ret
= vfwprintf( stream
, wxFormatConverter(format
), argptr
);
549 #ifndef wxCRT_VfprintfW
550 int wxCRT_VfprintfW( FILE *stream
, const wchar_t *format
, va_list argptr
)
552 return vfwprintf( stream
, wxFormatConverter(format
), argptr
);
556 #ifndef wxCRT_VprintfW
557 int wxCRT_VprintfW( const wchar_t *format
, va_list argptr
)
559 return vwprintf( wxFormatConverter(format
), argptr
);
563 #ifndef wxCRT_VsnprintfW
564 int wxCRT_VsnprintfW(wchar_t *str
, size_t size
, const wchar_t *format
, va_list argptr
)
566 return vswprintf( str
, size
, wxFormatConverter(format
), argptr
);
568 #endif // !wxCRT_VsnprintfW
570 // FIXME-UTF8: we only implement widechar version of vsnprintf() in wxprint.cpp,
571 // so this one has to convert the data for now
572 #ifndef wxCRT_VsnprintfA
573 int wxCRT_VsnprintfA(char *buf
, size_t len
, const char *format
, va_list argptr
)
575 wxWCharBuffer
wbuf(len
);
576 int rt
= wxCRT_VsnprintfW(wbuf
.data(), len
,
577 (const wchar_t*)wxConvLibc
.cMB2WC(format
),
579 if ( rt
< 0 || rt
>= len
)
582 if ( wxConvLibc
.FromWChar(buf
, len
, wbuf
) == wxCONV_FAILED
)
587 #endif // !wxCRT_VsnprintfA
589 #ifndef wxCRT_VsprintfW
590 int wxCRT_VsprintfW( wchar_t *str
, const wchar_t *format
, va_list argptr
)
592 // same as for wxSprintf()
593 return vswprintf(str
, INT_MAX
/ 4, wxFormatConverter(format
), argptr
);
598 int wxCRT_ScanfW(const wchar_t *format
, ...)
601 va_start(argptr
, format
);
603 int ret
= vwscanf(wxFormatConverter(format
), argptr
);
611 #ifndef wxCRT_SscanfW
612 int wxCRT_SscanfW(const wchar_t *str
, const wchar_t *format
, ...)
615 va_start(argptr
, format
);
617 int ret
= vswscanf(str
, wxFormatConverter(format
), argptr
);
625 #ifndef wxCRT_FscanfW
626 int wxCRT_FscanfW(FILE *stream
, const wchar_t *format
, ...)
629 va_start(argptr
, format
);
630 int ret
= vfwscanf(stream
, wxFormatConverter(format
), argptr
);
638 #ifndef wxCRT_VsscanfW
639 int wxCRT_VsscanfW(const wchar_t *str
, const wchar_t *format
, va_list argptr
)
641 return vswscanf(str
, wxFormatConverter(format
), argptr
);
646 // ----------------------------------------------------------------------------
647 // wrappers to printf and scanf function families
648 // ----------------------------------------------------------------------------
650 #if !wxUSE_UTF8_LOCALE_ONLY
651 int wxDoSprintfWchar(char *str
, const wxChar
*format
, ...)
654 va_start(argptr
, format
);
656 int rv
= wxVsprintf(str
, format
, argptr
);
661 #endif // !wxUSE_UTF8_LOCALE_ONLY
663 #if wxUSE_UNICODE_UTF8
664 int wxDoSprintfUtf8(char *str
, const char *format
, ...)
667 va_start(argptr
, format
);
669 int rv
= wxVsprintf(str
, format
, argptr
);
674 #endif // wxUSE_UNICODE_UTF8
678 #if !wxUSE_UTF8_LOCALE_ONLY
679 int wxDoSprintfWchar(wchar_t *str
, const wxChar
*format
, ...)
682 va_start(argptr
, format
);
684 int rv
= wxVsprintf(str
, format
, argptr
);
689 #endif // !wxUSE_UTF8_LOCALE_ONLY
691 #if wxUSE_UNICODE_UTF8
692 int wxDoSprintfUtf8(wchar_t *str
, const char *format
, ...)
695 va_start(argptr
, format
);
697 int rv
= wxVsprintf(str
, format
, argptr
);
702 #endif // wxUSE_UNICODE_UTF8
704 #endif // wxUSE_UNICODE
706 #if !wxUSE_UTF8_LOCALE_ONLY
707 int wxDoSnprintfWchar(char *str
, size_t size
, const wxChar
*format
, ...)
710 va_start(argptr
, format
);
712 int rv
= wxVsnprintf(str
, size
, format
, argptr
);
717 #endif // !wxUSE_UTF8_LOCALE_ONLY
719 #if wxUSE_UNICODE_UTF8
720 int wxDoSnprintfUtf8(char *str
, size_t size
, const char *format
, ...)
723 va_start(argptr
, format
);
725 int rv
= wxVsnprintf(str
, size
, format
, argptr
);
730 #endif // wxUSE_UNICODE_UTF8
734 #if !wxUSE_UTF8_LOCALE_ONLY
735 int wxDoSnprintfWchar(wchar_t *str
, size_t size
, const wxChar
*format
, ...)
738 va_start(argptr
, format
);
740 int rv
= wxVsnprintf(str
, size
, format
, argptr
);
745 #endif // !wxUSE_UTF8_LOCALE_ONLY
747 #if wxUSE_UNICODE_UTF8
748 int wxDoSnprintfUtf8(wchar_t *str
, size_t size
, const char *format
, ...)
751 va_start(argptr
, format
);
753 int rv
= wxVsnprintf(str
, size
, format
, argptr
);
758 #endif // wxUSE_UNICODE_UTF8
760 #endif // wxUSE_UNICODE
763 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
764 #define vsnprintf wx_fixed_vsnprintf
769 #if !wxUSE_UTF8_LOCALE_ONLY
770 static int ConvertStringToBuf(const wxString
& s
, char *out
, size_t outsize
)
772 const wxWX2WCbuf buf
= s
.wc_str();
774 size_t len
= wxConvLibc
.FromWChar(out
, outsize
, buf
);
775 if ( len
!= wxCONV_FAILED
)
778 return wxConvLibc
.FromWChar(NULL
, 0, buf
);
780 #endif // !wxUSE_UTF8_LOCALE_ONLY
782 #if wxUSE_UNICODE_UTF8
783 static int ConvertStringToBuf(const wxString
& s
, wchar_t *out
, size_t outsize
)
785 const wxWX2WCbuf
buf(s
.wc_str());
786 size_t len
= wxWcslen(buf
);
788 memcpy(out
, buf
, (len
+1) * sizeof(wchar_t));
789 // else: not enough space
792 #endif // wxUSE_UNICODE_UTF8
795 static size_t PrintfViaString(T
*out
, size_t outsize
,
796 const wxString
& format
, va_list argptr
)
799 s
.PrintfV(format
, argptr
);
801 return ConvertStringToBuf(s
, out
, outsize
);
803 #endif // wxUSE_UNICODE
805 int wxVsprintf(char *str
, const wxString
& format
, va_list argptr
)
807 #if wxUSE_UTF8_LOCALE_ONLY
808 return vsprintf(str
, format
.wx_str(), argptr
);
810 #if wxUSE_UNICODE_UTF8
811 if ( wxLocaleIsUtf8
)
812 return vsprintf(str
, format
.wx_str(), argptr
);
816 return PrintfViaString(str
, wxNO_LEN
, format
, argptr
);
818 return wxCRT_VsprintfA(str
, format
.mb_str(), argptr
);
824 int wxVsprintf(wchar_t *str
, const wxString
& format
, va_list argptr
)
826 #if wxUSE_UNICODE_WCHAR
827 return wxCRT_VsprintfW(str
, format
.wc_str(), argptr
);
828 #else // wxUSE_UNICODE_UTF8
829 #if !wxUSE_UTF8_LOCALE_ONLY
830 if ( !wxLocaleIsUtf8
)
831 return wxCRT_VsprintfW(str
, format
.wc_str(), argptr
);
834 return PrintfViaString(str
, wxNO_LEN
, format
, argptr
);
835 #endif // wxUSE_UNICODE_UTF8
837 #endif // wxUSE_UNICODE
839 int wxVsnprintf(char *str
, size_t size
, const wxString
& format
, va_list argptr
)
842 #if wxUSE_UTF8_LOCALE_ONLY
843 rv
= wxCRT_VsnprintfA(str
, size
, format
.wx_str(), argptr
);
845 #if wxUSE_UNICODE_UTF8
846 if ( wxLocaleIsUtf8
)
847 rv
= wxCRT_VsnprintfA(str
, size
, format
.wx_str(), argptr
);
852 // NB: if this code is called, then wxString::PrintV() would use the
853 // wchar_t* version of wxVsnprintf(), so it's safe to use PrintV()
855 rv
= PrintfViaString(str
, size
, format
, argptr
);
858 rv
= wxCRT_VsnprintfA(str
, size
, format
.mb_str(), argptr
);
862 // VsnprintfTestCase reveals that glibc's implementation of vswprintf
863 // doesn't nul terminate on truncation.
870 int wxVsnprintf(wchar_t *str
, size_t size
, const wxString
& format
, va_list argptr
)
874 #if wxUSE_UNICODE_WCHAR
875 rv
= wxCRT_VsnprintfW(str
, size
, format
.wc_str(), argptr
);
876 #else // wxUSE_UNICODE_UTF8
877 #if !wxUSE_UTF8_LOCALE_ONLY
878 if ( !wxLocaleIsUtf8
)
879 rv
= wxCRT_VsnprintfW(str
, size
, format
.wc_str(), argptr
);
883 // NB: if this code is called, then wxString::PrintV() would use the
884 // char* version of wxVsnprintf(), so it's safe to use PrintV()
886 rv
= PrintfViaString(str
, size
, format
, argptr
);
888 #endif // wxUSE_UNICODE_UTF8
890 // VsnprintfTestCase reveals that glibc's implementation of vswprintf
891 // doesn't nul terminate on truncation.
896 #endif // wxUSE_UNICODE
900 // ----------------------------------------------------------------------------
901 // ctype.h stuff (currently unused)
902 // ----------------------------------------------------------------------------
904 #if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
905 static inline WORD
wxMSW_ctype(wchar_t ch
)
908 GetStringTypeEx(LOCALE_USER_DEFAULT
, CT_CTYPE1
, &ch
, 1, &ret
);
912 int wxCRT_IsalnumW(wchar_t ch
) { return IsCharAlphaNumeric(ch
); }
913 int wxCRT_IsalphaW(wchar_t ch
) { return IsCharAlpha(ch
); }
914 int wxCRT_IscntrlW(wchar_t ch
) { return wxMSW_ctype(ch
) & C1_CNTRL
; }
915 int wxCRT_IsdigitW(wchar_t ch
) { return wxMSW_ctype(ch
) & C1_DIGIT
; }
916 int wxCRT_IsgraphW(wchar_t ch
) { return wxMSW_ctype(ch
) & (C1_DIGIT
|C1_PUNCT
|C1_ALPHA
); }
917 int wxCRT_IslowerW(wchar_t ch
) { return IsCharLower(ch
); }
918 int wxCRT_IsprintW(wchar_t ch
) { return wxMSW_ctype(ch
) & (C1_DIGIT
|C1_SPACE
|C1_PUNCT
|C1_ALPHA
); }
919 int wxCRT_IspunctW(wchar_t ch
) { return wxMSW_ctype(ch
) & C1_PUNCT
; }
920 int wxCRT_IsspaceW(wchar_t ch
) { return wxMSW_ctype(ch
) & C1_SPACE
; }
921 int wxCRT_IsupperW(wchar_t ch
) { return IsCharUpper(ch
); }
922 int wxCRT_IsxdigitW(wchar_t ch
) { return wxMSW_ctype(ch
) & C1_XDIGIT
; }
923 int wxCRT_Tolower(wchar_t ch
) { return (wchar_t)CharLower((LPTSTR
)(ch
)); }
924 int wxCRT_Toupper(wchar_t ch
) { return (wchar_t)CharUpper((LPTSTR
)(ch
)); }
927 #ifdef wxNEED_WX_MBSTOWCS
929 WXDLLEXPORT
size_t wxMbstowcs (wchar_t * out
, const char * in
, size_t outlen
)
939 const char* origin
= in
;
941 while (outlen
-- && *in
)
943 *out
++ = (wchar_t) *in
++;
951 WXDLLEXPORT
size_t wxWcstombs (char * out
, const wchar_t * in
, size_t outlen
)
961 const wchar_t* origin
= in
;
963 while (outlen
-- && *in
)
965 *out
++ = (char) *in
++;
973 #endif // wxNEED_WX_MBSTOWCS
975 #if defined(wxNEED_WX_CTYPE_H)
977 #include <CoreFoundation/CoreFoundation.h>
979 #define cfalnumset CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric)
980 #define cfalphaset CFCharacterSetGetPredefined(kCFCharacterSetLetter)
981 #define cfcntrlset CFCharacterSetGetPredefined(kCFCharacterSetControl)
982 #define cfdigitset CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit)
983 //CFCharacterSetRef cfgraphset = kCFCharacterSetControl && !' '
984 #define cflowerset CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter)
985 //CFCharacterSetRef cfprintset = !kCFCharacterSetControl
986 #define cfpunctset CFCharacterSetGetPredefined(kCFCharacterSetPunctuation)
987 #define cfspaceset CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline)
988 #define cfupperset CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter)
990 int wxCRT_IsalnumW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfalnumset
, ch
); }
991 int wxCRT_IsalphaW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfalphaset
, ch
); }
992 int wxCRT_IscntrlW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfcntrlset
, ch
); }
993 int wxCRT_IsdigitW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfdigitset
, ch
); }
994 int wxCRT_IsgraphW(wchar_t ch
) { return !CFCharacterSetIsCharacterMember(cfcntrlset
, ch
) && ch
!= ' '; }
995 int wxCRT_IslowerW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cflowerset
, ch
); }
996 int wxCRT_IsprintW(wchar_t ch
) { return !CFCharacterSetIsCharacterMember(cfcntrlset
, ch
); }
997 int wxCRT_IspunctW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfpunctset
, ch
); }
998 int wxCRT_IsspaceW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfspaceset
, ch
); }
999 int wxCRT_IsupperW(wchar_t ch
) { return CFCharacterSetIsCharacterMember(cfupperset
, ch
); }
1000 int wxCRT_IsxdigitW(wchar_t ch
) { return wxCRT_IsdigitW(ch
) || (ch
>='a' && ch
<='f') || (ch
>='A' && ch
<='F'); }
1002 // FIXME: these are broken!
1003 extern "C" int wxCRT_TolowerW(wchar_t ch
) { return (wchar_t)tolower((char)(ch
)); }
1004 extern "C" int wxCRT_ToupperW(wchar_t ch
) { return (wchar_t)toupper((char)(ch
)); }
1006 #endif // wxNEED_WX_CTYPE_H
1008 #ifndef wxCRT_StrdupA
1009 WXDLLEXPORT
char *wxCRT_StrdupA(const char *s
)
1011 return strcpy((char *)malloc(strlen(s
) + 1), s
);
1013 #endif // wxCRT_StrdupA
1015 #ifndef wxCRT_StrdupW
1016 WXDLLEXPORT
wchar_t * wxCRT_StrdupW(const wchar_t *pwz
)
1018 size_t size
= (wxWcslen(pwz
) + 1) * sizeof(wchar_t);
1019 wchar_t *ret
= (wchar_t *) malloc(size
);
1020 memcpy(ret
, pwz
, size
);
1023 #endif // wxCRT_StrdupW
1025 #ifndef wxCRT_StricmpA
1026 int WXDLLEXPORT
wxCRT_StricmpA(const char *psz1
, const char *psz2
)
1028 register char c1
, c2
;
1030 c1
= wxTolower(*psz1
++);
1031 c2
= wxTolower(*psz2
++);
1032 } while ( c1
&& (c1
== c2
) );
1035 #endif // !defined(wxCRT_StricmpA)
1037 #ifndef wxCRT_StricmpW
1038 int WXDLLEXPORT
wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
)
1040 register wchar_t c1
, c2
;
1042 c1
= wxTolower(*psz1
++);
1043 c2
= wxTolower(*psz2
++);
1044 } while ( c1
&& (c1
== c2
) );
1047 #endif // !defined(wxCRT_StricmpW)
1049 #ifndef wxCRT_StrnicmpA
1050 int WXDLLEXPORT
wxCRT_StrnicmpA(const char *s1
, const char *s2
, size_t n
)
1052 // initialize the variables just to suppress stupid gcc warning
1053 register char c1
= 0, c2
= 0;
1054 while (n
&& ((c1
= wxTolower(*s1
)) == (c2
= wxTolower(*s2
)) ) && c1
) n
--, s1
++, s2
++;
1056 if (c1
< c2
) return -1;
1057 if (c1
> c2
) return 1;
1061 #endif // !defined(wxCRT_StrnicmpA)
1063 #ifndef wxCRT_StrnicmpW
1064 int WXDLLEXPORT
wxCRT_StrnicmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
)
1066 // initialize the variables just to suppress stupid gcc warning
1067 register wchar_t c1
= 0, c2
= 0;
1068 while (n
&& ((c1
= wxTolower(*s1
)) == (c2
= wxTolower(*s2
)) ) && c1
) n
--, s1
++, s2
++;
1070 if (c1
< c2
) return -1;
1071 if (c1
> c2
) return 1;
1075 #endif // !defined(wxCRT_StrnicmpW)
1077 // ----------------------------------------------------------------------------
1078 // string.h functions
1079 // ----------------------------------------------------------------------------
1081 #ifndef wxCRT_StrcatW
1082 WXDLLEXPORT
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
)
1084 wchar_t *ret
= dest
;
1085 while (*dest
) dest
++;
1086 while ((*dest
++ = *src
++));
1091 #ifndef wxCRT_StrchrW
1092 WXDLLEXPORT
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
)
1094 // be careful here as the terminating NUL makes part of the string
1105 #ifndef wxCRT_StrcmpW
1106 WXDLLEXPORT
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
)
1108 while ((*s1
== *s2
) && *s1
) s1
++, s2
++;
1109 if ((wxUChar
)*s1
< (wxUChar
)*s2
) return -1;
1110 if ((wxUChar
)*s1
> (wxUChar
)*s2
) return 1;
1115 #ifndef wxCRT_StrcpyW
1116 WXDLLEXPORT
wchar_t * wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
)
1118 wchar_t *ret
= dest
;
1119 while ((*dest
++ = *src
++));
1124 template<typename T
>
1125 static inline size_t wxCRT_DoStrlen(const T
*s
)
1134 // these two (and wxCRT_StrncmpW below) are extern "C" because they are needed
1135 // by regex code, the rest isn't needed, so it's not declared as extern "C"
1136 #ifndef wxCRT_StrlenA
1137 WXDLLEXPORT
size_t wxCRT_StrlenA(const char *s
)
1138 { return wxCRT_DoStrlen(s
); }
1140 #ifndef wxCRT_StrlenW
1141 extern "C" WXDLLEXPORT
size_t wxCRT_StrlenW(const wchar_t *s
)
1142 { return wxCRT_DoStrlen(s
); }
1145 #ifndef wxCRT_StrncatW
1146 WXDLLEXPORT
wchar_t * wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
)
1148 wchar_t *ret
= dest
;
1149 while (*dest
) dest
++;
1150 while (n
&& (*dest
++ = *src
++)) n
--;
1155 #ifndef wxCRT_StrncmpW
1157 WXDLLEXPORT
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
)
1159 while (n
&& (*s1
== *s2
) && *s1
) n
--, s1
++, s2
++;
1161 if ((wxUChar
)*s1
< (wxUChar
)*s2
) return -1;
1162 if ((wxUChar
)*s1
> (wxUChar
)*s2
) return 1;
1168 #ifndef wxCRT_StrncpyW
1169 WXDLLEXPORT
wchar_t * wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
)
1171 wchar_t *ret
= dest
;
1172 while (n
&& (*dest
++ = *src
++)) n
--;
1173 while (n
) *dest
++=0, n
--; // the docs specify padding with zeroes
1178 #ifndef wxCRT_StrpbrkW
1179 WXDLLEXPORT
const wchar_t * wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
)
1181 while (*s
&& !wxCRT_Strchr(accept
, *s
))
1184 return *s
? s
: NULL
;
1188 #ifndef wxCRT_StrrchrW
1189 WXDLLEXPORT
const wchar_t * wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
)
1191 const wchar_t *ret
= NULL
;
1204 #ifndef wxCRT_StrspnW
1205 WXDLLEXPORT
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
)
1208 while (wxCRT_Strchr(accept
, *s
++)) len
++;
1213 #ifndef wxCRT_StrstrW
1214 WXDLLEXPORT
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
)
1216 wxASSERT_MSG( needle
!= NULL
, _T("NULL argument in wxCRT_Strstr") );
1218 // VZ: this is not exactly the most efficient string search algorithm...
1220 const size_t len
= wxStrlen(needle
);
1222 while ( const wchar_t *fnd
= wxCRT_Strchr(haystack
, *needle
) )
1224 if ( !wxCRT_Strncmp(fnd
, needle
, len
) )
1234 #ifndef wxCRT_StrtodW
1235 WXDLLEXPORT
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
)
1237 const wchar_t *start
= nptr
;
1239 // FIXME: only correct for C locale
1240 while (wxIsspace(*nptr
)) nptr
++;
1241 if (*nptr
== wxT('+') || *nptr
== wxT('-')) nptr
++;
1242 while (wxIsdigit(*nptr
)) nptr
++;
1243 if (*nptr
== wxT('.')) {
1245 while (wxIsdigit(*nptr
)) nptr
++;
1247 if (*nptr
== wxT('E') || *nptr
== wxT('e')) {
1249 if (*nptr
== wxT('+') || *nptr
== wxT('-')) nptr
++;
1250 while (wxIsdigit(*nptr
)) nptr
++;
1253 wxString
data(nptr
, nptr
-start
);
1254 wxWX2MBbuf dat
= data
.mb_str(wxConvLibc
);
1255 char *rdat
= wxMBSTRINGCAST dat
;
1256 double ret
= strtod(dat
, &rdat
);
1258 if (endptr
) *endptr
= (wchar_t *)(start
+ (rdat
- (const char *)dat
));
1262 #endif // !wxCRT_StrtodW
1264 #ifndef wxCRT_StrtolW
1265 WXDLLEXPORT
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
)
1267 const wchar_t *start
= nptr
;
1269 // FIXME: only correct for C locale
1270 while (wxIsspace(*nptr
)) nptr
++;
1271 if (*nptr
== wxT('+') || *nptr
== wxT('-')) nptr
++;
1272 if (((base
== 0) || (base
== 16)) &&
1273 (nptr
[0] == wxT('0') && nptr
[1] == wxT('x'))) {
1277 else if ((base
== 0) && (nptr
[0] == wxT('0'))) base
= 8;
1278 else if (base
== 0) base
= 10;
1280 while ((wxIsdigit(*nptr
) && (*nptr
- wxT('0') < base
)) ||
1281 (wxIsalpha(*nptr
) && (wxToupper(*nptr
) - wxT('A') + 10 < base
))) nptr
++;
1283 wxString
data(start
, nptr
-start
);
1284 wxWX2MBbuf dat
= data
.mb_str(wxConvLibc
);
1285 char *rdat
= wxMBSTRINGCAST dat
;
1286 long int ret
= strtol(dat
, &rdat
, base
);
1288 if (endptr
) *endptr
= (wchar_t *)(start
+ (rdat
- (const char *)dat
));
1292 #endif // !wxCRT_StrtolW
1294 #ifndef wxCRT_StrtoulW
1295 WXDLLEXPORT
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
)
1297 return (unsigned long int) wxCRT_StrtolW(nptr
, endptr
, base
);
1303 #ifndef wxCRT_GetenvW
1304 wchar_t* WXDLLEXPORT
wxCRT_GetenvW(const wchar_t *name
)
1306 // NB: buffer returned by getenv() is allowed to be overwritten next
1307 // time getenv() is called, so it is OK to use static string
1308 // buffer to hold the data.
1309 static wxWCharBuffer
value((wxChar
*)NULL
);
1310 value
= wxConvLibc
.cMB2WX(getenv(wxConvLibc
.cWX2MB(name
)));
1311 return value
.data();
1313 #endif // !wxCRT_GetenvW
1315 #ifndef wxCRT_StrftimeW
1317 wxCRT_StrftimeW(wchar_t *s
, size_t maxsize
, const wchar_t *fmt
, const struct tm
*tm
)
1322 wxCharBuffer
buf(maxsize
);
1324 wxCharBuffer
bufFmt(wxConvLibc
.cWX2MB(fmt
));
1328 size_t ret
= strftime(buf
.data(), maxsize
, bufFmt
, tm
);
1332 wxWCharBuffer wbuf
= wxConvLibc
.cMB2WX(buf
);
1336 wxCRT_StrncpyW(s
, wbuf
, maxsize
);
1337 return wxCRT_StrlenW(s
);
1339 #endif // !wxCRT_StrftimeW
1341 #endif // wxUSE_WCHAR_T
1343 template<typename T
>
1344 static wxULongLong_t
1345 wxCRT_StrtoullBase(const T
* nptr
, T
** endptr
, int base
, T
* sign
)
1347 wxULongLong_t sum
= 0;
1348 wxString
wxstr(nptr
);
1349 wxString::const_iterator i
= wxstr
.begin();
1350 wxString::const_iterator end
= wxstr
.end();
1353 while ( i
!= end
&& wxIsspace(*i
) ) i
++;
1355 // Starts with sign?
1360 if ( c
== wxT('+') || c
== wxT('-') )
1368 if ( i
!= end
&& *i
== wxT('0') )
1373 if ( *i
== wxT('x') && (base
== 16 || base
== 0) )
1381 *endptr
= (T
*) nptr
;
1382 wxSET_ERRNO(EINVAL
);
1393 for ( ; i
!= end
; i
++ )
1398 if ( c
>= wxT('0') )
1400 if ( c
<= wxT('9') )
1403 n
= wxTolower(c
) - wxT('a') + 10;
1408 if ( n
>= (unsigned int)base
)
1409 // Invalid character (for this base)
1412 wxULongLong_t prevsum
= sum
;
1413 sum
= (sum
* base
) + n
;
1415 if ( sum
< prevsum
)
1417 wxSET_ERRNO(ERANGE
);
1424 *endptr
= (T
*)(nptr
+ (i
- wxstr
.begin()));
1430 template<typename T
>
1431 static wxULongLong_t
wxCRT_DoStrtoull(const T
* nptr
, T
** endptr
, int base
)
1434 wxULongLong_t uval
= wxCRT_StrtoullBase(nptr
, endptr
, base
, &sign
);
1436 if ( sign
== wxT('-') )
1438 wxSET_ERRNO(ERANGE
);
1445 template<typename T
>
1446 static wxLongLong_t
wxCRT_DoStrtoll(const T
* nptr
, T
** endptr
, int base
)
1449 wxULongLong_t uval
= wxCRT_StrtoullBase(nptr
, endptr
, base
, &sign
);
1450 wxLongLong_t val
= 0;
1452 if ( sign
== wxT('-') )
1454 if ( uval
<= wxULL(wxINT64_MAX
+1) )
1456 if ( uval
== wxULL(wxINT64_MAX
+1))
1457 val
= -((wxLongLong_t
)wxINT64_MAX
) - 1;
1459 val
= -((wxLongLong_t
)uval
);
1463 wxSET_ERRNO(ERANGE
);
1466 else if ( uval
<= wxINT64_MAX
)
1472 wxSET_ERRNO(ERANGE
);
1478 #ifndef wxCRT_StrtollA
1479 wxLongLong_t
wxCRT_StrtollA(const char* nptr
, char** endptr
, int base
)
1480 { return wxCRT_DoStrtoll(nptr
, endptr
, base
); }
1482 #ifndef wxCRT_StrtollW
1483 wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
, wchar_t** endptr
, int base
)
1484 { return wxCRT_DoStrtoll(nptr
, endptr
, base
); }
1487 #ifndef wxCRT_StrtoullA
1488 wxULongLong_t
wxCRT_StrtoullA(const char* nptr
, char** endptr
, int base
)
1489 { return wxCRT_DoStrtoull(nptr
, endptr
, base
); }
1491 #ifndef wxCRT_StrtoullW
1492 wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
, wchar_t** endptr
, int base
)
1493 { return wxCRT_DoStrtoull(nptr
, endptr
, base
); }
1496 // ----------------------------------------------------------------------------
1497 // functions which we may need even if !wxUSE_WCHAR_T
1498 // ----------------------------------------------------------------------------
1500 template<typename T
>
1501 static T
*wxCRT_DoStrtok(T
*psz
, const T
*delim
, T
**save_ptr
)
1510 psz
+= wxStrspn(psz
, delim
);
1513 *save_ptr
= (T
*)NULL
;
1518 psz
= wxStrpbrk(psz
, delim
);
1521 *save_ptr
= (T
*)NULL
;
1526 *save_ptr
= psz
+ 1;
1532 #ifndef wxCRT_StrtokA
1533 char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
)
1534 { return wxCRT_DoStrtok(psz
, delim
, save_ptr
); }
1536 #ifndef wxCRT_StrtokW
1537 wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
)
1538 { return wxCRT_DoStrtok(psz
, delim
, save_ptr
); }
1541 // ----------------------------------------------------------------------------
1542 // missing C RTL functions
1543 // ----------------------------------------------------------------------------
1545 #ifdef wxNEED_STRDUP
1547 char *strdup(const char *s
)
1549 char *dest
= (char*) malloc( strlen( s
) + 1 ) ;
1551 strcpy( dest
, s
) ;
1554 #endif // wxNEED_STRDUP
1556 #if defined(__WXWINCE__) && (_WIN32_WCE <= 211)
1558 void *calloc( size_t num
, size_t size
)
1560 void** ptr
= (void **)malloc(num
* size
);
1561 memset( ptr
, 0, num
* size
);
1565 #endif // __WXWINCE__ <= 211
1568 int wxCRT_RemoveW(const wchar_t *path
)
1570 return ::DeleteFile(path
) == 0;
1574 #ifndef wxCRT_TmpnamW
1575 wchar_t *wxCRT_TmpnamW(wchar_t *s
)
1577 // tmpnam_r() returns NULL if s=NULL, do the same
1578 wxCHECK_MSG( s
, NULL
, "wxTmpnam must be called with a buffer" );
1581 #define L_tmpnam 1024
1583 wxCharBuffer
buf(L_tmpnam
);
1586 wxConvLibc
.ToWChar(s
, L_tmpnam
+1, buf
.data());
1589 #endif // !wxCRT_TmpnamW
1592 // ============================================================================
1594 // ============================================================================
1596 #if wxUSE_UNICODE_UTF8
1598 #if !wxUSE_UTF8_LOCALE_ONLY
1599 bool wxLocaleIsUtf8
= false; // the safer setting if not known
1602 static bool wxIsLocaleUtf8()
1604 // NB: we intentionally don't use wxLocale::GetSystemEncodingName(),
1605 // because a) it may be unavailable in some builds and b) has slightly
1606 // different semantics (default locale instead of current)
1608 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
1609 // GNU libc provides current character set this way (this conforms to
1611 const char *charset
= nl_langinfo(CODESET
);
1614 // "UTF-8" is used by modern glibc versions, but test other variants
1615 // as well, just in case:
1616 if ( strcmp(charset
, "UTF-8") == 0 ||
1617 strcmp(charset
, "utf-8") == 0 ||
1618 strcmp(charset
, "UTF8") == 0 ||
1619 strcmp(charset
, "utf8") == 0 )
1626 // check if we're running under the "C" locale: it is 7bit subset
1627 // of UTF-8, so it can be safely used with the UTF-8 build:
1628 const char *lc_ctype
= setlocale(LC_CTYPE
, NULL
);
1630 (strcmp(lc_ctype
, "C") == 0 || strcmp(lc_ctype
, "POSIX") == 0) )
1635 // we don't know what charset libc is using, so assume the worst
1640 void wxUpdateLocaleIsUtf8()
1642 #if wxUSE_UTF8_LOCALE_ONLY
1643 if ( !wxIsLocaleUtf8() )
1645 wxLogFatalError(_T("This program requires UTF-8 locale to run."));
1647 #else // !wxUSE_UTF8_LOCALE_ONLY
1648 wxLocaleIsUtf8
= wxIsLocaleUtf8();
1652 #endif // wxUSE_UNICODE_UTF8
1654 // ============================================================================
1655 // wx wrappers for CRT functions
1656 // ============================================================================
1658 #if wxUSE_UNICODE_WCHAR
1659 #define CALL_ANSI_OR_UNICODE(callA, callW) return callW
1660 #elif wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY
1661 #define CALL_ANSI_OR_UNICODE(callA, callW) \
1662 return wxLocaleIsUtf8 ? callA : callW
1663 #else // ANSI or UTF8 only
1664 #define CALL_ANSI_OR_UNICODE(callA, callW) return callA
1667 int wxPuts(const wxString
& s
)
1669 CALL_ANSI_OR_UNICODE(wxCRT_PutsA(s
.mb_str()),
1670 wxCRT_PutsW(s
.wc_str()));
1673 int wxFputs(const wxString
& s
, FILE *stream
)
1675 CALL_ANSI_OR_UNICODE(wxCRT_FputsA(s
.mb_str(), stream
),
1676 wxCRT_FputsW(s
.wc_str(), stream
));
1679 int wxFputc(const wxUniChar
& c
, FILE *stream
)
1681 #if !wxUSE_UNICODE // FIXME-UTF8: temporary, remove this with ANSI build
1682 return wxCRT_FputcA((char)c
, stream
);
1684 CALL_ANSI_OR_UNICODE(wxCRT_FputsA(c
.AsUTF8(), stream
),
1685 wxCRT_FputcW((wchar_t)c
, stream
));
1689 void wxPerror(const wxString
& s
)
1691 #ifdef wxCRT_PerrorW
1692 CALL_ANSI_OR_UNICODE(wxCRT_PerrorA(s
.mb_str()), wxCRT_PerrorW(s
.wc_str()));
1694 wxCRT_PerrorA(s
.mb_str());
1698 wchar_t *wxFgets(wchar_t *s
, int size
, FILE *stream
)
1700 wxCHECK_MSG( s
, NULL
, "empty buffer passed to wxFgets()" );
1702 wxCharBuffer
buf(size
- 1);
1703 // FIXME: this reads too little data if wxConvLibc uses UTF-8 ('size' wide
1704 // characters may be encoded by up to 'size'*4 bytes), but what
1706 if ( wxFgets(buf
.data(), size
, stream
) == NULL
)
1709 if ( wxConvLibc
.ToWChar(s
, size
, buf
, wxNO_LEN
) == wxCONV_FAILED
)
1715 // ----------------------------------------------------------------------------
1716 // wxScanf() and friends
1717 // ----------------------------------------------------------------------------
1720 int wxVsscanf(const char *str
, const char *format
, va_list ap
)
1721 { return wxCRT_VsscanfA(str
, format
, ap
); }
1722 int wxVsscanf(const wchar_t *str
, const wchar_t *format
, va_list ap
)
1723 { return wxCRT_VsscanfW(str
, format
, ap
); }
1724 int wxVsscanf(const wxCharBuffer
& str
, const char *format
, va_list ap
)
1725 { return wxCRT_VsscanfA(str
, format
, ap
); }
1726 int wxVsscanf(const wxWCharBuffer
& str
, const wchar_t *format
, va_list ap
)
1727 { return wxCRT_VsscanfW(str
, format
, ap
); }
1728 int wxVsscanf(const wxString
& str
, const char *format
, va_list ap
)
1729 { return wxCRT_VsscanfA(str
.mb_str(), format
, ap
); }
1730 int wxVsscanf(const wxString
& str
, const wchar_t *format
, va_list ap
)
1731 { return wxCRT_VsscanfW(str
.wc_str(), format
, ap
); }
1732 int wxVsscanf(const wxCStrData
& str
, const char *format
, va_list ap
)
1733 { return wxCRT_VsscanfA(str
.AsCharBuf(), format
, ap
); }
1734 int wxVsscanf(const wxCStrData
& str
, const wchar_t *format
, va_list ap
)
1735 { return wxCRT_VsscanfW(str
.AsWCharBuf(), format
, ap
); }
1736 #endif // !__VISUALC__