1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4 // Author: Joel Farley, Ove Kåven
5 // Modified by: Vadim Zeitlin, Robert Roebling
8 // Copyright: (c) 1998-2002 wxWindows dev team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "wxchar.h"
19 #include "wx/defs.h" // for wxUSE_UNICODE
21 // ----------------------------------------------------------------------------
22 // check whether we have wchar_t and which size it is if we do
23 // ----------------------------------------------------------------------------
25 #if !defined(wxUSE_WCHAR_T)
26 #if defined(__WIN16__)
27 // no wchar_t under Win16 regadrless of compiler used
28 #define wxUSE_WCHAR_T 0
29 #elif defined(__UNIX__)
30 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
31 #define wxUSE_WCHAR_T 1
33 #define wxUSE_WCHAR_T 0
35 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
36 #define wxUSE_WCHAR_T 0
37 #elif defined(__WATCOMC__)
38 #define wxUSE_WCHAR_T 0
39 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
40 #define wxUSE_WCHAR_T 0
42 // add additional compiler checks if this fails
43 #define wxUSE_WCHAR_T 1
45 #endif // !defined(wxUSE_WCHAR_T)
47 // Unicode support requires wchar_t
48 #if wxUSE_UNICODE && !wxUSE_WCHAR_T
49 #error "wchar_t must be available in Unicode build"
52 // ----------------------------------------------------------------------------
53 // standard headers we need here
55 // NB: don't include any wxWindows headers here because almost of them include
57 // ----------------------------------------------------------------------------
59 // Required for wxPrintf() etc
62 // Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac
63 // and VC++ for Windows CE don't provide it
64 #if !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
65 // use #define, not inline wrapper, as it is tested with #ifndef below
66 #define wxStrdupA strdup
69 // non Unix compilers which do have wchar.h (but not tchar.h which is included
70 // below and which includes wchar.h anyhow).
71 // Actually MinGW has tchar.h, but it does not include wchar.h
72 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__)
80 // the current (as of Nov 2002) version of cygwin has a bug in its
81 // wchar.h -- there is no extern "C" around the declarations in it and
82 // this results in linking errors later; also, at least on some
83 // Cygwin versions, wchar.h requires sys/types.h
85 #include <sys/types.h>
92 #elif defined(HAVE_WCSTR_H)
93 // old compilers have relevant declarations here
95 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
96 // include stdlib.h for wchar_t
98 #endif // HAVE_WCHAR_H
99 #endif // wxUSE_WCHAR_T
101 // ----------------------------------------------------------------------------
102 // define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type
103 // mapped to either char or wchar_t depending on the ASCII/Unicode mode and have
104 // the function mapping _tfoo() -> foo() or wfoo()
105 // ----------------------------------------------------------------------------
107 // VC++ and BC++ starting with 5.2 have TCHAR support
109 #define wxHAVE_TCHAR_SUPPORT
110 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
111 #define wxHAVE_TCHAR_SUPPORT
113 #elif defined(__WATCOMC__)
114 #define wxHAVE_TCHAR_SUPPORT
115 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
116 #define wxHAVE_TCHAR_SUPPORT
120 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
121 // VZ: the old VisualAge definitions were completely wrong and had no
122 // chance at all to work in Unicode build anyhow so let's pretend that
123 // VisualAge does _not_ support TCHAR for the moment (as indicated by
124 // "0 &&" above) until someone really has time to delve into Unicode
127 // VisualAge 4.0+ supports TCHAR
128 #define wxHAVE_TCHAR_SUPPORT
129 #endif // compilers with (good) TCHAR support
135 #ifdef wxHAVE_TCHAR_SUPPORT
136 // get TCHAR definition if we've got it
139 // we surely do have wchar_t if we have TCHAR
140 #ifndef wxUSE_WCHAR_T
141 #define wxUSE_WCHAR_T 1
142 #endif // !defined(wxUSE_WCHAR_T)
144 // and we also do have wcslen()
148 #endif // wxHAVE_TCHAR_SUPPORT
150 // ----------------------------------------------------------------------------
151 // define wxChar type
152 // ----------------------------------------------------------------------------
154 // TODO: define wxCharInt to be equal to either int or wint_t?
158 typedef signed char wxSChar
;
159 typedef unsigned char wxUChar
;
161 // VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as
162 // signed/unsigned version of it which (a) makes sense to me (unlike
163 // char wchar_t is always unsigned) and (b) was how the previous
164 // definitions worked so keep it like this
166 // GNU libc has __WCHAR_TYPE__ which requires special treatment, see
168 #if !defined(__WCHAR_TYPE__) || \
169 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
171 typedef wchar_t wxChar
;
172 typedef wchar_t wxSChar
;
173 typedef wchar_t wxUChar
;
174 #else // __WCHAR_TYPE__ and gcc < 2.96
175 // VS: wxWindows used to define wxChar as __WCHAR_TYPE__ here. However,
176 // this doesn't work with new GCC 3.x compilers because wchar_t is
177 // C++'s builtin type in the new standard. OTOH, old compilers (GCC
178 // 2.x) won't accept new definition of wx{S,U}Char, therefore we
179 // have to define wxChar conditionally depending on detected
180 // compiler & compiler version.
181 // with old definition of wxChar.
182 typedef __WCHAR_TYPE__ wxChar
;
183 typedef __WCHAR_TYPE__ wxSChar
;
184 typedef __WCHAR_TYPE__ wxUChar
;
185 #endif // __WCHAR_TYPE__
186 #endif // ASCII/Unicode
188 // ----------------------------------------------------------------------------
189 // define _T() and related macros
190 // ----------------------------------------------------------------------------
192 // BSD systems define _T() to be something different in ctype.h, override it
193 #if defined(__FreeBSD__) || defined(__DARWIN__)
198 // could already be defined by tchar.h (it's quasi standard)
204 #endif // ASCII/Unicode
205 #endif // !defined(_T)
207 // although global macros with such names are normally bad, we want to have
208 // another name for _T() which should be used to avoid confusion between _T()
209 // and _() in wxWindows sources
212 // Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs
214 #define __XFILE__(x) wxT(x)
215 #define __TFILE__ __XFILE__(__FILE__)
219 #define __XDATE__(x) wxT(x)
220 #define __TDATE__ __XDATE__(__DATE__)
224 #define __XTIME__(x) wxT(x)
225 #define __TTIME__ __XTIME__(__TIME__)
228 // ----------------------------------------------------------------------------
229 // define wxFoo() function for each standard foo() function whose signature
230 // (exceptionally including the return type) includes any mention of char:
231 // wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
232 // the same signature but with char replaced by wxChar which allows us to use
233 // it in Unicode build as well
234 // ----------------------------------------------------------------------------
236 #ifdef wxHAVE_TCHAR_SUPPORT
240 #define wxIsalnum _istalnum
241 #define wxIsalpha _istalpha
242 #define wxIsctrl _istctrl
243 #define wxIsdigit _istdigit
244 #define wxIsgraph _istgraph
245 #define wxIslower _istlower
246 #define wxIsprint _istprint
247 #define wxIspunct _istpunct
248 #define wxIsspace _istspace
249 #define wxIsupper _istupper
250 #define wxIsxdigit _istxdigit
251 #define wxTolower _totlower
252 #define wxToupper _totupper
255 #define wxSetlocale _tsetlocale
257 // string.h functions
258 #define wxStrcat _tcscat
259 #define wxStrchr _tcschr
260 #define wxStrcmp _tcscmp
261 #define wxStrcoll _tcscoll
262 #define wxStrcpy _tcscpy
263 #define wxStrcspn _tcscspn
264 #define wxStrdupW _wcsdup // notice the 'W'!
265 #define wxStrftime _tcsftime
266 #define wxStricmp _tcsicmp
267 #define wxStrnicmp _tcsnicmp
268 #define wxStrlen_ _tcslen // used in wxStrlen inline function
269 #define wxStrncat _tcsncat
270 #define wxStrncmp _tcsncmp
271 #define wxStrncpy _tcsncpy
272 #define wxStrpbrk _tcspbrk
273 #define wxStrrchr _tcsrchr
274 #define wxStrspn _tcsspn
275 #define wxStrstr _tcsstr
276 #define wxStrtod _tcstod
277 #define wxStrtol _tcstol
278 #define wxStrtoul _tcstoul
279 #define wxStrxfrm _tcsxfrm
282 #define wxFgetc _fgettc
283 #define wxFgetchar _fgettchar
284 #define wxFgets _fgetts
285 #define wxFopen _tfopen
286 #define wxFputc _fputtc
287 #define wxFputchar _fputtchar
288 #define wxFprintf _ftprintf
289 #define wxFputs _fputts
290 #define wxFreopen _tfreopen
291 #define wxFscanf _ftscanf
292 #define wxGetc _gettc
293 #define wxGetchar _gettchar
294 #define wxGets _getts
295 #define wxPerror _tperror
296 #define wxPrintf _tprintf
297 #define wxPutc _puttc
298 #define wxPutchar _puttchar
299 #define wxPuts _putts
300 #define wxScanf _tscanf
301 #define wxSprintf _stprintf
302 #define wxSscanf _stscanf
303 #define wxTmpnam _ttmpnam
304 #define wxUngetc _tungetc
305 #define wxVfprintf _vftprintf
306 #define wxVprintf _vtprintf
307 #define wxVsscanf _vstscanf
308 #define wxVsprintf _vstprintf
310 // special case: not all TCHAR-aware compilers have those
311 #if defined(__VISUALC__) || \
312 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
313 #define wxVsnprintf_ _vsntprintf
314 #define wxSnprintf_ _sntprintf
317 // special case: these functions are missing under Win9x with Unicows so we
318 // have to implement them ourselves
319 #if wxUSE_UNICODE_MSLU
320 #define wxRemove wxMSLU__tremove
321 #define wxRename wxMSLU__trename
324 #define wxRemove DeleteFile
326 #define wxRemove _tremove
327 #define wxRename _trename
331 // stdlib.h functions
334 // #define wxAtof _tttof -- notice that there is no such thing (why?)
335 #define wxGetenv _tgetenv
336 #define wxSystem _tsystem
339 #define wxAsctime _tasctime
340 #define wxCtime _tctime
341 #else // !TCHAR-aware compilers
345 // this is probably glibc-specific
346 #if defined(__WCHAR_TYPE__)
347 // ctype.h functions (wctype.h)
348 #define wxIsalnum iswalnum
349 #define wxIsalpha iswalpha
350 #define wxIsctrl iswcntrl
351 #define wxIsdigit iswdigit
352 #define wxIsgraph iswgraph
353 #define wxIslower iswlower
354 #define wxIsprint iswprint
355 #define wxIspunct iswpunct
356 #define wxIsspace iswspace
357 #define wxIsupper iswupper
358 #define wxIsxdigit iswxdigit
360 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
361 // /usr/include/wctype.h incorrectly declares translations
362 // tables which provokes tons of compile-time warnings -- try
364 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
365 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
367 #define wxTolower towlower
368 #define wxToupper towupper
371 // string.h functions (wchar.h)
372 #define wxStrcat wcscat
373 #define wxStrchr wcschr
374 #define wxStrcmp wcscmp
375 #define wxStrcoll wcscoll
376 #define wxStrcpy wcscpy
377 #define wxStrcspn wcscspn
378 #define wxStrlen_ wxWcslen // wxStrlen_() is used in wxStrlen()
379 #define wxStrncat wcsncat
380 #define wxStrncmp wcsncmp
381 #define wxStrncpy wcsncpy
382 #define wxStrpbrk wcspbrk
383 #define wxStrrchr wcsrchr
384 #define wxStrspn wcsspn
385 #define wxStrstr wcsstr
386 #define wxStrtod wcstod
387 #define wxStrtol wcstol
388 #define wxStrtoul wcstoul
389 #define wxStrxfrm wcsxfrm
391 #define wxFgetc fgetwc
392 #define wxFgetchar fgetwchar
393 #define wxFgets fgetws
394 #define wxFputc fputwc
395 #define wxFputchar fputwchar
397 #define wxGetchar getwchar
399 #define wxUngetc ungetwc
403 #define wxPutchar wputchar
405 #define wxFputs fputws
407 #define wxNEED_FPUTWC
411 int wxFputs(const wxChar
*ch
, FILE *stream
);
412 int wxPutc(wxChar ch
, FILE *stream
);
414 #define wxPuts(ws) wxFputs(ws, stdout)
415 #define wxPutchar(wch) wxPutc(wch, stdout)
418 // we need %s to %ls conversion for printf and scanf etc
419 #define wxNEED_PRINTF_CONVERSION
421 // glibc doesn't have wide char equivalents of the other stuff so
422 // use our own versions
423 #define wxNEED_WX_STDIO_H
424 #define wxNEED_WX_STDLIB_H
425 #define wxNEED_WX_TIME_H
426 #elif defined(__MWERKS__) && ( defined(macintosh) || defined(__MACH__) )
427 // ctype.h functions (wctype.h)
428 #define wxIsalnum iswalnum
429 #define wxIsalpha iswalpha
430 #define wxIsctrl iswcntrl
431 #define wxIsdigit iswdigit
432 #define wxIsgraph iswgraph
433 #define wxIslower iswlower
434 #define wxIsprint iswprint
435 #define wxIspunct iswpunct
436 #define wxIsspace iswspace
437 #define wxIsupper iswupper
438 #define wxIsxdigit iswxdigit
439 #define wxTolower towlower
440 #define wxToupper towupper
442 // string.h functions (wchar.h)
443 #define wxStrcat wcscat
444 #define wxStrchr wcschr
445 #define wxStrcmp wcscmp
446 #define wxStrcoll wcscoll
447 #define wxStrcpy wcscpy
448 #define wxStrcspn wcscspn
449 #define wxStrlen_ wxWcslen // wxStrlen_() is used in wxStrlen()
450 #define wxStrncat wcsncat
451 #define wxStrncmp wcsncmp
452 #define wxStrncpy wcsncpy
453 #define wxStrpbrk wcspbrk
454 #define wxStrrchr wcsrchr
455 #define wxStrspn wcsspn
456 #define wxStrstr wcsstr
457 #define wxStrtod wcstod
458 #define wxStrtol wcstol
459 #define wxStrtoul wcstoul
460 #define wxStrxfrm wcsxfrm
462 #define wxFgetc fgetwc
463 #define wxFgetchar fgetwchar
464 #define wxFgets fgetws
465 #define wxFputc fputwc
466 #define wxFputchar fputwchar
468 #define wxGetchar getwchar
470 #define wxUngetc ungetwc
472 #define wxNEED_PRINTF_CONVERSION
475 #define wxPutchar putwchar
476 #define wxFputs fputws
480 #define wxNEED_WX_STDIO_H
482 // stdlib.h functions
486 #define wxGetenv(a) ((wxChar*)NULL)
487 #define wxSystem(a) ((int)NULL)
490 #define wxAsctime wasciitime
491 #define wxCtime wctime
492 // #define wxStrftime wcsftime
495 #define wxNEED_FPUTWC
499 int wxFputs(const wxChar *ch, FILE *stream);
500 int wxPutc(wxChar ch, FILE *stream);
502 #define wxPuts(ws) wxFputs(ws, stdout)
503 #define wxPutchar(wch) wxPutc(wch, stdout)
505 // we need %s to %ls conversion for printf and scanf etc
506 #define wxNEED_PRINTF_CONVERSION
507 // glibc doesn't have wide char equivalents of the other stuff so
508 // use our own versions
509 #define wxNEED_WX_STDIO_H
510 #define wxNEED_WX_STDLIB_H
512 #define wxNEED_WX_TIME_H
513 #else // !metrowerks for apple
514 #error "Please define wide character functions for your environment"
521 #define wxIsalnum isalnum
522 #define wxIsalpha isalpha
523 #define wxIsctrl isctrl
524 #define wxIsdigit isdigit
525 #define wxIsgraph isgraph
526 #define wxIslower islower
527 #define wxIsprint isprint
528 #define wxIspunct ispunct
529 #define wxIsspace isspace
530 #define wxIsupper isupper
531 #define wxIsxdigit isxdigit
532 #define wxTolower tolower
533 #define wxToupper toupper
536 #define wxSetlocale setlocale
538 // string.h functions
539 #define wxStrcat strcat
540 #define wxStrchr strchr
541 #define wxStrcmp strcmp
542 #define wxStrcoll strcoll
543 #define wxStrcpy strcpy
544 #define wxStrcspn strcspn
546 // wxStricmp and wxStrnicmp are defined below
547 #define wxStrlen_ strlen // used in wxStrlen inline function
548 #define wxStrncat strncat
549 #define wxStrncmp strncmp
550 #define wxStrncpy strncpy
551 #define wxStrpbrk strpbrk
552 #define wxStrrchr strrchr
553 #define wxStrspn strspn
554 #define wxStrstr strstr
555 #define wxStrtod strtod
557 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
559 #define wxStrtol strtol
560 #define wxStrtoul strtoul
561 #define wxStrxfrm strxfrm
564 #define wxFopen fopen
565 #define wxFreopen freopen
566 #define wxRemove remove
567 #define wxRename rename
569 #define wxPerror perror
570 #define wxTmpnam tmpnam
572 #define wxFgetc fgetc
573 #define wxFgetchar fgetchar
574 #define wxFgets fgets
575 #define wxFputc fputc
576 #define wxFputs fputs
577 #define wxFputchar fputchar
578 #define wxFprintf fprintf
579 #define wxFscanf fscanf
581 #define wxGetchar getchar
583 #define wxPrintf printf
585 #define wxPutchar putchar
587 #define wxScanf scanf
588 #define wxSprintf sprintf
589 #define wxSscanf sscanf
590 #define wxUngetc ungetc
591 #define wxVfprintf vfprintf
592 #define wxVprintf vprintf
593 #define wxVsscanf vsscanf
594 #define wxVsprintf vsprintf
596 // stdlib.h functions
600 #define wxGetenv getenv
601 #define wxSystem system
604 #define wxAsctime asctime
605 #define wxCtime ctime
606 #define wxStrftime strftime
607 #endif // Unicode/ASCII
608 #endif // TCHAR-aware compilers/the others
610 // ----------------------------------------------------------------------------
611 // various special cases
612 // ----------------------------------------------------------------------------
614 // define wxStricmp and wxStrnicmp for various compilers
616 // note that in Unicode mode we definitely are going to need our own version
617 #if !defined(wxStricmp) && !wxUSE_UNICODE
618 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
619 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
620 defined(__EMX__) || defined(__DJGPP__)
621 #define wxStricmp stricmp
622 #define wxStrnicmp strnicmp
623 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
624 (defined(__MWERKS__) && defined(__INTEL__))
625 #define wxStricmp _stricmp
626 #define wxStrnicmp _strnicmp
627 #elif defined(__UNIX__) || defined(__GNUWIN32__)
628 #define wxStricmp strcasecmp
629 #define wxStrnicmp strncasecmp
630 // #else -- use wxWindows implementation
632 #endif // !defined(wxStricmp)
634 // define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as
635 // it's used in wx/buffer.h -- and also might be used just below by wxStrlen()
636 // when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen)
639 #define wxWcslen wcslen
641 inline size_t wxWcslen(const wchar_t *s
)
650 #endif // wxUSE_WCHAR_T
652 // checks whether the passed in pointer is NULL and if the string is empty
653 inline bool wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
655 // safe version of strlen() (returns 0 if passed NULL pointer)
656 inline size_t wxStrlen(const wxChar
*psz
) { return psz
? wxStrlen_(psz
) : 0; }
658 // each of strdup() and wcsdup() may or may not be available but we need both
659 // of them anyhow for wx/buffer.h so we define the missing one(s) in
660 // wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
661 // defined -- if this is somehow not the case in some situations, please
662 // correct that and not the lines here
664 #define wxStrdup wxStrdupW
666 #define wxStrdup wxStrdupA
669 WXDLLIMPEXP_BASE
bool wxOKlibc(); // for internal use
671 // ----------------------------------------------------------------------------
672 // printf() family saga
673 // ----------------------------------------------------------------------------
676 For some systems vsnprintf() exists in the system libraries but not in the
677 headers, so we need to declare it ourselves to be able to use it.
679 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
681 int vsnprintf(char *str
, size_t size
, const char *format
, va_list ap
);
682 #endif // !HAVE_VSNPRINTF_DECL
685 First of all, we always want to define safe snprintf() function to be used
686 instead of sprintf(). Some compilers already have it (or rather vsnprintf()
687 which we really need...), otherwise we implement it using our own printf()
690 We define function with a trailing underscore here because the real one is a
691 wrapper around it as explained below
695 #if defined(__MWERKS__)
696 #define HAVE_WCSRTOMBS 1
697 #define HAVE_VSWPRINTF 1
699 #if defined(HAVE__VSNWPRINTF)
700 #define wxVsnprintf_ _vsnwprintf
701 /* MinGW?MSVCRT has the wrong vswprintf */
702 #elif defined(HAVE_VSWPRINTF) && !defined(__MINGW32__)
703 #define wxVsnprintf_ vswprintf
706 // all versions of CodeWarrior supported by wxWindows apparently have
708 #if defined(HAVE_VSNPRINTF) || defined(__MWERKS__)
709 // assume we have snprintf() too if we have vsnprintf()
710 #define wxVsnprintf_ vsnprintf
711 #define wxSnprintf_ snprintf
714 #endif // wxVsnprintf_ not defined yet
717 // no [v]snprintf(), cook our own
718 WXDLLIMPEXP_BASE
int wxSnprintf_(wxChar
*buf
, size_t len
, const wxChar
*format
,
719 ...) ATTRIBUTE_PRINTF_3
;
722 WXDLLIMPEXP_BASE
int wxVsnprintf_(wxChar
*buf
, size_t len
, const wxChar
*format
,
727 In Unicode mode we need to have all standard functions such as wprintf() and
728 so on but not all systems have them so use our own implementations in this
731 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
732 #define wxNEED_WPRINTF
736 More Unicode complications: although both ANSI C and C++ define a number of
737 wide character functions such as wprintf(), not all environments have them.
738 Worse, those which do have different behaviours: under Windows, %s format
739 specifier changes its meaning in Unicode build and expects a Unicode string
740 while under Unix/POSIX it still means an ASCII string even for wprintf() and
741 %ls has to be used for wide strings.
743 We choose to always emulate Windows behaviour as more useful for us so even
744 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
746 However, if we don't have any vswprintf() at all we don't need to redefine
747 anything as our own wxVsnprintf_() already behaves as needed.
750 #undef wxNEED_PRINTF_CONVERSION
753 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
754 // we need to implement all wide character printf and scanf functions
755 // either because we don't have them at all or because they don't have the
758 #include <stdio.h> // for FILE
760 int wxScanf( const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_1
;
761 int wxSscanf( const wxChar
*str
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
762 int wxFscanf( FILE *stream
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
763 int wxVsscanf( const wxChar
*str
, const wxChar
*format
, va_list ap
);
764 int wxPrintf( const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_1
;
765 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
766 int wxFprintf( FILE *stream
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
767 int wxVfprintf( FILE *stream
, const wxChar
*format
, va_list ap
);
768 int wxVprintf( const wxChar
*format
, va_list ap
);
769 int wxVsprintf( wxChar
*str
, const wxChar
*format
, va_list ap
);
770 #endif // wxNEED_PRINTF_CONVERSION
772 // these 2 can be simply mapped to the versions with underscore at the end
773 // if we don't have to do the conversion
774 #ifdef wxNEED_PRINTF_CONVERSION
775 int wxSnprintf( wxChar
*str
, size_t size
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_3
;
776 int wxVsnprintf( wxChar
*str
, size_t size
, const wxChar
*format
, va_list ap
);
778 #define wxSnprintf wxSnprintf_
779 #define wxVsnprintf wxVsnprintf_
782 // ----------------------------------------------------------------------------
783 // various functions which might not be available in libc and for which we
784 // provide our own replacements in wxchar.cpp
785 // ----------------------------------------------------------------------------
789 // VZ: note that this is never defined currently
790 #ifdef wxNEED_WX_CTYPE_H
791 WXDLLIMPEXP_BASE
int wxIsalnum(wxChar ch
);
792 WXDLLIMPEXP_BASE
int wxIsalpha(wxChar ch
);
793 WXDLLIMPEXP_BASE
int wxIsctrl(wxChar ch
);
794 WXDLLIMPEXP_BASE
int wxIsdigit(wxChar ch
);
795 WXDLLIMPEXP_BASE
int wxIsgraph(wxChar ch
);
796 WXDLLIMPEXP_BASE
int wxIslower(wxChar ch
);
797 WXDLLIMPEXP_BASE
int wxIsprint(wxChar ch
);
798 WXDLLIMPEXP_BASE
int wxIspunct(wxChar ch
);
799 WXDLLIMPEXP_BASE
int wxIsspace(wxChar ch
);
800 WXDLLIMPEXP_BASE
int wxIsupper(wxChar ch
);
801 WXDLLIMPEXP_BASE
int wxIsxdigit(wxChar ch
);
802 WXDLLIMPEXP_BASE
int wxTolower(wxChar ch
);
803 WXDLLIMPEXP_BASE
int wxToupper(wxChar ch
);
804 #endif // wxNEED_WX_CTYPE_H
806 // under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks
807 // the file parsing -- this may be true for 5.0 as well, update #ifdef then
808 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
810 #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
814 // string.h functions
816 // VZ: this is never defined neither currently
817 #ifdef wxNEED_WX_STRING_H
818 WXDLLIMPEXP_BASE wxChar
* wxStrcat(wxChar
*dest
, const wxChar
*src
);
819 WXDLLIMPEXP_BASE
const wxChar
* wxStrchr(const wxChar
*s
, wxChar c
);
820 WXDLLIMPEXP_BASE wxChar
* wxStrchr(wxChar
*s
, wxChar c
)
821 { return (wxChar
*)wxStrchr((const wxChar
*)s
, c
); }
822 WXDLLIMPEXP_BASE
int wxStrcmp(const wxChar
*s1
, const wxChar
*s2
);
823 WXDLLIMPEXP_BASE
int wxStrcoll(const wxChar
*s1
, const wxChar
*s2
);
824 WXDLLIMPEXP_BASE wxChar
* wxStrcpy(wxChar
*dest
, const wxChar
*src
);
825 WXDLLIMPEXP_BASE
size_t wxStrcspn(const wxChar
*s
, const wxChar
*reject
);
826 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar
*s
);
827 WXDLLIMPEXP_BASE wxChar
* wxStrncat(wxChar
*dest
, const wxChar
*src
, size_t n
);
828 WXDLLIMPEXP_BASE
int wxStrncmp(const wxChar
*s1
, const wxChar
*s2
, size_t n
);
829 WXDLLIMPEXP_BASE wxChar
* wxStrncpy(wxChar
*dest
, const wxChar
*src
, size_t n
);
830 WXDLLIMPEXP_BASE
const wxChar
* wxStrpbrk(const wxChar
*s
, const wxChar
*accept
);
831 WXDLLIMPEXP_BASE wxChar
* wxStrpbrk(wxChar
*s
, const wxChar
*accept
)
832 { return (wxChar
*)wxStrpbrk((const wxChar
*)s
, accept
); }
833 WXDLLIMPEXP_BASE
const wxChar
* wxStrrchr(const wxChar
*s
, wxChar c
);
834 WXDLLIMPEXP_BASE wxChar
* wxStrrchr(wxChar
*s
, wxChar c
)
835 { return (wxChar
*)wxStrrchr((const wxChar
*)s
, c
); }
836 WXDLLIMPEXP_BASE
size_t wxStrspn(const wxChar
*s
, const wxChar
*accept
);
837 WXDLLIMPEXP_BASE
const wxChar
* wxStrstr(const wxChar
*haystack
, const wxChar
*needle
);
838 WXDLLIMPEXP_BASE wxChar
*wxStrstr(wxChar
*haystack
, const wxChar
*needle
)
839 { return (wxChar
*)wxStrstr((const wxChar
*)haystack
, needle
); }
840 WXDLLIMPEXP_BASE
double wxStrtod(const wxChar
*nptr
, wxChar
**endptr
);
841 WXDLLIMPEXP_BASE
long int wxStrtol(const wxChar
*nptr
, wxChar
**endptr
, int base
);
842 WXDLLIMPEXP_BASE
unsigned long int wxStrtoul(const wxChar
*nptr
, wxChar
**endptr
, int base
);
843 WXDLLIMPEXP_BASE
size_t wxStrxfrm(wxChar
*dest
, const wxChar
*src
, size_t n
);
844 #endif // wxNEED_WX_STRING_H
847 WXDLLIMPEXP_BASE
char *wxStrdupA(const char *psz
);
851 WXDLLIMPEXP_BASE
wchar_t *wxStrdupW(const wchar_t *pwz
);
855 WXDLLIMPEXP_BASE
int wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
);
859 WXDLLIMPEXP_BASE
int wxStrnicmp(const wxChar
*psz1
, const wxChar
*psz2
, size_t len
);
863 WXDLLIMPEXP_BASE wxChar
* wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
867 class WXDLLIMPEXP_BASE wxWCharBuffer
;
868 WXDLLIMPEXP_BASE wxWCharBuffer
wxSetlocale(int category
, const wxChar
*locale
);
872 #ifdef wxNEED_WX_STDIO_H
874 WXDLLIMPEXP_BASE
FILE * wxFopen(const wxChar
*path
, const wxChar
*mode
);
875 WXDLLIMPEXP_BASE
FILE * wxFreopen(const wxChar
*path
, const wxChar
*mode
, FILE *stream
);
876 WXDLLIMPEXP_BASE
int wxRemove(const wxChar
*path
);
877 WXDLLIMPEXP_BASE
int wxRename(const wxChar
*oldpath
, const wxChar
*newpath
);
879 // *printf() family is handled separately
880 #endif // wxNEED_WX_STDIO_H
883 // stdlib.h functions
885 WXDLLIMPEXP_BASE
double wxAtof(const wxChar
*psz
);
888 #ifdef wxNEED_WX_STDLIB_H
889 WXDLLIMPEXP_BASE
int wxAtoi(const wxChar
*psz
);
890 WXDLLIMPEXP_BASE
long wxAtol(const wxChar
*psz
);
891 WXDLLIMPEXP_BASE wxChar
* wxGetenv(const wxChar
*name
);
892 WXDLLIMPEXP_BASE
int wxSystem(const wxChar
*psz
);
897 #ifdef wxNEED_WX_TIME_H
898 #if defined(__MWERKS__) && defined(macintosh)
901 WXDLLIMPEXP_BASE
size_t wxStrftime(wxChar
*s
, size_t max
,
902 const wxChar
*fmt
, const struct tm
*tm
);
903 #endif // wxNEED_WX_TIME_H
905 // missing functions in some WinCE versions
907 #if (_WIN32_WCE < 300)
908 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
910 WXDLLIMPEXP_BASE
char* strdup(const char* s
);
912 #if _WIN32_WCE <= 211
913 WXDLLIMPEXP_BASE
int isspace(int c
);
914 WXDLLIMPEXP_BASE
int isascii( int c
);
918 // ----------------------------------------------------------------------------
919 // multibyte to wide char conversion functions and macros
920 // ----------------------------------------------------------------------------
923 // multibyte<->widechar conversion
924 WXDLLIMPEXP_BASE
size_t wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
925 WXDLLIMPEXP_BASE
size_t wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
928 #define wxMB2WX wxMB2WC
929 #define wxWX2MB wxWC2MB
930 #define wxWC2WX wxStrncpy
931 #define wxWX2WC wxStrncpy
933 #define wxMB2WX wxStrncpy
934 #define wxWX2MB wxStrncpy
935 #define wxWC2WX wxWC2MB
936 #define wxWX2WC wxMB2WC
938 #else // !wxUSE_UNICODE
939 // No wxUSE_WCHAR_T: we have to do something (JACS)
940 #define wxMB2WC wxStrncpy
941 #define wxWC2MB wxStrncpy
942 #define wxMB2WX wxStrncpy
943 #define wxWX2MB wxStrncpy
944 #define wxWC2WX wxWC2MB
945 #define wxWX2WC wxMB2WC
948 #endif //_WX_WXCHAR_H_