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(__APPLE__)
16 #pragma interface "wxchar.h"
19 // ----------------------------------------------------------------------------
20 // first deal with Unicode setting: wxUSE_UNICODE should be defined as 0 or 1
21 // and is used by wxWindows, _UNICODE and/or UNICODE may be defined or used by
22 // the system headers so bring these settings in sync
23 // ----------------------------------------------------------------------------
25 // set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined
26 #if defined(_UNICODE) || defined(UNICODE)
28 #define wxUSE_UNICODE 1
31 #define wxUSE_UNICODE 0
35 // and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1...
45 // check whether we have wchar_t
46 #if !defined(wxUSE_WCHAR_T)
47 #if defined(__WIN16__)
48 // no wchar_t under Win16 regadrless of compiler used
49 #define wxUSE_WCHAR_T 0
50 #elif defined(__UNIX__)
51 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
52 #define wxUSE_WCHAR_T 1
54 #define wxUSE_WCHAR_T 0
56 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
57 #define wxUSE_WCHAR_T 0
58 #elif defined(__WATCOMC__)
59 #define wxUSE_WCHAR_T 0
60 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
61 #define wxUSE_WCHAR_T 0
63 // add additional compiler checks if this fails
64 #define wxUSE_WCHAR_T 1
66 #endif // !defined(wxUSE_WCHAR_T)
68 // Unicode support requires wchar_t
69 #if wxUSE_UNICODE && !wxUSE_WCHAR_T
70 #error "wchar_t must be available in Unicode build"
73 // ----------------------------------------------------------------------------
74 // standard headers we need here
76 // NB: don't include any wxWindows headers here because almost of them include
78 // ----------------------------------------------------------------------------
80 // Required for wxPrintf() etc
83 // Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac
84 // and VC++ for Windows CE don't provide it
85 #if !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
86 // use #define, not inline wrapper, as it is tested with #ifndef below
87 #define wxStrdupA strdup
90 // non Unix compilers which do have wchar.h (but not tchar.h which is included
91 // below and which includes wchar.h anyhow).
92 // Actually MinGW has tchar.h, but it does not include wchar.h
93 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__)
101 // the current (as of Nov 2002) version of cygwin has a bug in its
102 // wchar.h -- there is no extern "C" around the declarations in it and
103 // this results in linking errors later; also, at least on some
104 // Cygwin versions, wchar.h requires sys/types.h
106 #include <sys/types.h>
113 #elif defined(HAVE_WCSTR_H)
114 // old compilers have relevant declarations here
116 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
117 // include stdlib.h for wchar_t
119 #endif // HAVE_WCHAR_H
120 #endif // wxUSE_WCHAR_T
122 // ----------------------------------------------------------------------------
123 // define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type
124 // mapped to either char or wchar_t depending on the ASCII/Unicode mode and have
125 // the function mapping _tfoo() -> foo() or wfoo()
126 // ----------------------------------------------------------------------------
128 // VC++ and BC++ starting with 5.2 have TCHAR support
130 #define wxHAVE_TCHAR_SUPPORT
131 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
132 #define wxHAVE_TCHAR_SUPPORT
134 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
135 #define wxHAVE_TCHAR_SUPPORT
139 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
140 // VZ: the old VisualAge definitions were completely wrong and had no
141 // chance at all to work in Unicode build anyhow so let's pretend that
142 // VisualAge does _not_ support TCHAR for the moment (as indicated by
143 // "0 &&" above) until someone really has time to delve into Unicode
146 // VisualAge 4.0+ supports TCHAR
147 #define wxHAVE_TCHAR_SUPPORT
148 #endif // compilers with (good) TCHAR support
150 #ifdef wxHAVE_TCHAR_SUPPORT
151 // get TCHAR definition if we've got it
154 // we surely do have wchar_t if we have TCHAR
155 #ifndef wxUSE_WCHAR_T
156 #define wxUSE_WCHAR_T 1
157 #endif // !defined(wxUSE_WCHAR_T)
159 // and we also do have wcslen()
163 #endif // wxHAVE_TCHAR_SUPPORT
165 // ----------------------------------------------------------------------------
166 // define wxChar type
167 // ----------------------------------------------------------------------------
169 // TODO: define wxCharInt to be equal to either int or wint_t?
173 typedef signed char wxSChar
;
174 typedef unsigned char wxUChar
;
176 // VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as
177 // signed/unsigned version of it which (a) makes sense to me (unlike
178 // char wchar_t is always unsigned) and (b) was how the previous
179 // definitions worked so keep it like this
181 // GNU libc has __WCHAR_TYPE__ which requires special treatment, see
183 #if !defined(__WCHAR_TYPE__) || \
184 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
186 typedef wchar_t wxChar
;
187 typedef wchar_t wxSChar
;
188 typedef wchar_t wxUChar
;
189 #else // __WCHAR_TYPE__ and gcc < 2.96
190 // VS: wxWindows used to define wxChar as __WCHAR_TYPE__ here. However,
191 // this doesn't work with new GCC 3.x compilers because wchar_t is
192 // C++'s builtin type in the new standard. OTOH, old compilers (GCC
193 // 2.x) won't accept new definition of wx{S,U}Char, therefore we
194 // have to define wxChar conditionally depending on detected
195 // compiler & compiler version.
196 // with old definition of wxChar.
197 typedef __WCHAR_TYPE__ wxChar
;
198 typedef __WCHAR_TYPE__ wxSChar
;
199 typedef __WCHAR_TYPE__ wxUChar
;
200 #endif // __WCHAR_TYPE__
201 #endif // ASCII/Unicode
203 // ----------------------------------------------------------------------------
204 // define _T() and related macros
205 // ----------------------------------------------------------------------------
207 // BSD systems define _T() to be something different in ctype.h, override it
208 #if defined(__FreeBSD__) || defined(__DARWIN__)
213 // could already be defined by tchar.h (it's quasi standard)
219 #endif // ASCII/Unicode
220 #endif // !defined(_T)
222 // although global macros with such names are normally bad, we want to have
223 // another name for _T() which should be used to avoid confusion between _T()
224 // and _() in wxWindows sources
227 // Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs
229 #define __XFILE__(x) wxT(x)
230 #define __TFILE__ __XFILE__(__FILE__)
234 #define __XDATE__(x) wxT(x)
235 #define __TDATE__ __XDATE__(__DATE__)
239 #define __XTIME__(x) wxT(x)
240 #define __TTIME__ __XTIME__(__TIME__)
243 // ----------------------------------------------------------------------------
244 // define wxFoo() function for each standard foo() function whose signature
245 // (exceptionally including the return type) includes any mention of char:
246 // wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
247 // the same signature but with char replaced by wxChar which allows us to use
248 // it in Unicode build as well
249 // ----------------------------------------------------------------------------
251 #ifdef wxHAVE_TCHAR_SUPPORT
255 #define wxIsalnum _istalnum
256 #define wxIsalpha _istalpha
257 #define wxIsctrl _istctrl
258 #define wxIsdigit _istdigit
259 #define wxIsgraph _istgraph
260 #define wxIslower _istlower
261 #define wxIsprint _istprint
262 #define wxIspunct _istpunct
263 #define wxIsspace _istspace
264 #define wxIsupper _istupper
265 #define wxIsxdigit _istxdigit
266 #define wxTolower _totlower
267 #define wxToupper _totupper
270 #define wxSetlocale _tsetlocale
272 // string.h functions
273 #define wxStrcat _tcscat
274 #define wxStrchr _tcschr
275 #define wxStrcmp _tcscmp
276 #define wxStrcoll _tcscoll
277 #define wxStrcpy _tcscpy
278 #define wxStrcspn _tcscspn
279 #define wxStrdupW _wcsdup // notice the 'W'!
280 #define wxStrftime _tcsftime
281 #define wxStricmp _tcsicmp
282 #define wxStrnicmp _tcsnicmp
283 #define wxStrlen_ _tcslen // used in wxStrlen inline function
284 #define wxStrncat _tcsncat
285 #define wxStrncmp _tcsncmp
286 #define wxStrncpy _tcsncpy
287 #define wxStrpbrk _tcspbrk
288 #define wxStrrchr _tcsrchr
289 #define wxStrspn _tcsspn
290 #define wxStrstr _tcsstr
291 #define wxStrtod _tcstod
292 #define wxStrtol _tcstol
293 #define wxStrtoul _tcstoul
294 #define wxStrxfrm _tcsxfrm
297 #define wxFgetc _fgettc
298 #define wxFgetchar _fgettchar
299 #define wxFgets _fgetts
300 #define wxFopen _tfopen
301 #define wxFputc _fputtc
302 #define wxFputchar _fputtchar
303 #define wxFprintf _ftprintf
304 #define wxFputs _fputts
305 #define wxFreopen _tfreopen
306 #define wxFscanf _ftscanf
307 #define wxGetc _gettc
308 #define wxGetchar _gettchar
309 #define wxGets _getts
310 #define wxPerror _tperror
311 #define wxPrintf _tprintf
312 #define wxPutc _puttc
313 #define wxPutchar _puttchar
314 #define wxPuts _putts
315 #define wxScanf _tscanf
316 #define wxSprintf _stprintf
317 #define wxSscanf _stscanf
318 #define wxTmpnam _ttmpnam
319 #define wxUngetc _tungetc
320 #define wxVfprintf _vftprintf
321 #define wxVprintf _vtprintf
322 #define wxVsscanf _vstscanf
323 #define wxVsprintf _vstprintf
325 // special case: not all TCHAR-aware compilers have those
326 #if defined(__VISUALC__) || \
327 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
328 #define wxVsnprintf_ _vsntprintf
329 #define wxSnprintf_ _sntprintf
332 // special case: these functions are missing under Win9x with Unicows so we
333 // have to implement them ourselves
334 #if wxUSE_UNICODE_MSLU
335 #define wxRemove wxMSLU__tremove
336 #define wxRename wxMSLU__trename
338 #define wxRemove _tremove
339 #define wxRename _trename
342 // stdlib.h functions
345 // #define wxAtof _tttof -- notice that there is no such thing (why?)
346 #define wxGetenv _tgetenv
347 #define wxSystem _tsystem
350 #define wxAsctime _tasctime
351 #define wxCtime _tctime
352 #else // !TCHAR-aware compilers
356 // this is probably glibc-specific
357 #if defined(__WCHAR_TYPE__)
358 // ctype.h functions (wctype.h)
359 #define wxIsalnum iswalnum
360 #define wxIsalpha iswalpha
361 #define wxIsctrl iswcntrl
362 #define wxIsdigit iswdigit
363 #define wxIsgraph iswgraph
364 #define wxIslower iswlower
365 #define wxIsprint iswprint
366 #define wxIspunct iswpunct
367 #define wxIsspace iswspace
368 #define wxIsupper iswupper
369 #define wxIsxdigit iswxdigit
371 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
372 // /usr/include/wctype.h incorrectly declares translations
373 // tables which provokes tons of compile-time warnings -- try
375 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
376 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
378 #define wxTolower towlower
379 #define wxToupper towupper
382 // string.h functions (wchar.h)
383 #define wxStrcat wcscat
384 #define wxStrchr wcschr
385 #define wxStrcmp wcscmp
386 #define wxStrcoll wcscoll
387 #define wxStrcpy wcscpy
388 #define wxStrcspn wcscspn
389 #define wxStrlen_ wxWcslen // wxStrlen_() is used in wxStrlen()
390 #define wxStrncat wcsncat
391 #define wxStrncmp wcsncmp
392 #define wxStrncpy wcsncpy
393 #define wxStrpbrk wcspbrk
394 #define wxStrrchr wcsrchr
395 #define wxStrspn wcsspn
396 #define wxStrstr wcsstr
397 #define wxStrtod wcstod
398 #define wxStrtol wcstol
399 #define wxStrtoul wcstoul
400 #define wxStrxfrm wcsxfrm
402 #define wxFgetc fgetwc
403 #define wxFgetchar fgetwchar
404 #define wxFgets fgetws
405 #define wxFputc fputwc
406 #define wxFputchar fputwchar
408 #define wxGetchar getwchar
410 #define wxUngetc ungetwc
414 #define wxPutchar wputchar
416 #define wxFputs fputws
418 #define wxNEED_FPUTWC
422 int wxFputs(const wxChar
*ch
, FILE *stream
);
423 int wxPutc(wxChar ch
, FILE *stream
);
425 #define wxPuts(ws) wxFputs(ws, stdout)
426 #define wxPutchar(wch) wxPutc(wch, stdout)
429 // we need %s to %ls conversion for printf and scanf etc
430 #define wxNEED_PRINTF_CONVERSION
432 // glibc doesn't have wide char equivalents of the other stuff so
433 // use our own versions
434 #define wxNEED_WX_STDIO_H
435 #define wxNEED_WX_STDLIB_H
436 #define wxNEED_WX_TIME_H
437 #elif defined(__MWERKS__) && defined(macintosh)
438 // ctype.h functions (wctype.h)
439 #define wxIsalnum iswalnum
440 #define wxIsalpha iswalpha
441 #define wxIsctrl iswcntrl
442 #define wxIsdigit iswdigit
443 #define wxIsgraph iswgraph
444 #define wxIslower iswlower
445 #define wxIsprint iswprint
446 #define wxIspunct iswpunct
447 #define wxIsspace iswspace
448 #define wxIsupper iswupper
449 #define wxIsxdigit iswxdigit
450 #define wxTolower towlower
451 #define wxToupper towupper
453 // string.h functions (wchar.h)
454 #define wxStrcat wcscat
455 #define wxStrchr wcschr
456 #define wxStrcmp wcscmp
457 #define wxStrcoll wcscoll
458 #define wxStrcpy wcscpy
459 #define wxStrcspn wcscspn
460 #define wxStrlen_ wxWcslen // wxStrlen_() is used in wxStrlen()
461 #define wxStrncat wcsncat
462 #define wxStrncmp wcsncmp
463 #define wxStrncpy wcsncpy
464 #define wxStrpbrk wcspbrk
465 #define wxStrrchr wcsrchr
466 #define wxStrspn wcsspn
467 #define wxStrstr wcsstr
468 #define wxStrtod wcstod
469 #define wxStrtol wcstol
470 #define wxStrtoul wcstoul
471 #define wxStrxfrm wcsxfrm
473 #define wxFgetc fgetwc
474 #define wxFgetchar fgetwchar
475 #define wxFgets fgetws
476 #define wxFputc fputwc
477 #define wxFputchar fputwchar
479 #define wxGetchar getwchar
481 #define wxUngetc ungetwc
483 #define wxNEED_FPUTWC
487 int wxFputs(const wxChar
*ch
, FILE *stream
);
488 int wxPutc(wxChar ch
, FILE *stream
);
490 #define wxPuts(ws) wxFputs(ws, stdout)
491 #define wxPutchar(wch) wxPutc(wch, stdout)
493 // we need %s to %ls conversion for printf and scanf etc
494 #define wxNEED_PRINTF_CONVERSION
495 // glibc doesn't have wide char equivalents of the other stuff so
496 // use our own versions
497 #define wxNEED_WX_STDIO_H
498 #define wxNEED_WX_STDLIB_H
499 #define wxNEED_WX_TIME_H
500 #else // !metrowerks for apple
501 #error "Please define wide character functions for your environment"
508 #define wxIsalnum isalnum
509 #define wxIsalpha isalpha
510 #define wxIsctrl isctrl
511 #define wxIsdigit isdigit
512 #define wxIsgraph isgraph
513 #define wxIslower islower
514 #define wxIsprint isprint
515 #define wxIspunct ispunct
516 #define wxIsspace isspace
517 #define wxIsupper isupper
518 #define wxIsxdigit isxdigit
519 #define wxTolower tolower
520 #define wxToupper toupper
523 #define wxSetlocale setlocale
525 // string.h functions
526 #define wxStrcat strcat
527 #define wxStrchr strchr
528 #define wxStrcmp strcmp
529 #define wxStrcoll strcoll
530 #define wxStrcpy strcpy
531 #define wxStrcspn strcspn
533 // wxStricmp and wxStrnicmp are defined below
534 #define wxStrlen_ strlen // used in wxStrlen inline function
535 #define wxStrncat strncat
536 #define wxStrncmp strncmp
537 #define wxStrncpy strncpy
538 #define wxStrpbrk strpbrk
539 #define wxStrrchr strrchr
540 #define wxStrspn strspn
541 #define wxStrstr strstr
542 #define wxStrtod strtod
544 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
546 #define wxStrtol strtol
547 #define wxStrtoul strtoul
548 #define wxStrxfrm strxfrm
551 #define wxFopen fopen
552 #define wxFreopen freopen
553 #define wxPerror perror
554 #define wxRemove remove
555 #define wxRename rename
556 #define wxTmpnam tmpnam
558 #define wxFgetc fgetc
559 #define wxFgetchar fgetchar
560 #define wxFgets fgets
561 #define wxFputc fputc
562 #define wxFputchar fputchar
563 #define wxFprintf fprintf
564 #define wxFscanf fscanf
566 #define wxGetchar getchar
568 #define wxPrintf printf
570 #define wxPutchar putchar
572 #define wxScanf scanf
573 #define wxSprintf sprintf
574 #define wxSscanf sscanf
575 #define wxUngetc ungetc
576 #define wxVfprintf vfprintf
577 #define wxVprintf vprintf
578 #define wxVsscanf vsscanf
579 #define wxVsprintf vsprintf
581 // stdlib.h functions
585 #define wxGetenv getenv
586 #define wxSystem system
589 #define wxAsctime asctime
590 #define wxCtime ctime
591 #define wxStrftime strftime
592 #endif // Unicode/ASCII
593 #endif // TCHAR-aware compilers/the others
595 // ----------------------------------------------------------------------------
596 // various special cases
597 // ----------------------------------------------------------------------------
599 // define wxStricmp and wxStrnicmp for various compilers
601 // note that in Unicode mode we definitely are going to need our own version
602 #if !defined(wxStricmp) && !wxUSE_UNICODE
603 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
604 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
605 defined(__EMX__) || defined(__DJGPP__)
606 #define wxStricmp stricmp
607 #define wxStrnicmp strnicmp
608 #elif defined(__SC__) || defined(__VISUALC__) || \
609 (defined(__MWERKS__) && defined(__INTEL__))
610 #define wxStricmp _stricmp
611 #define wxStrnicmp _strnicmp
612 #elif defined(__UNIX__) || defined(__GNUWIN32__)
613 #define wxStricmp strcasecmp
614 #define wxStrnicmp strncasecmp
615 // #else -- use wxWindows implementation
617 #endif // !defined(wxStricmp)
619 // define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as
620 // it's used in wx/buffer.h -- and also might be used just below by wxStrlen()
621 // when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen)
624 #define wxWcslen wcslen
626 inline size_t wxWcslen(const wchar_t *s
)
635 #endif // wxUSE_WCHAR_T
637 // checks whether the passed in pointer is NULL and if the string is empty
638 inline bool wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
640 // safe version of strlen() (returns 0 if passed NULL pointer)
641 inline size_t wxStrlen(const wxChar
*psz
) { return psz
? wxStrlen_(psz
) : 0; }
643 // each of strdup() and wcsdup() may or may not be available but we need both
644 // of them anyhow for wx/buffer.h so we define the missing one(s) in
645 // wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
646 // defined -- if this is somehow not the case in some situations, please
647 // correct that and not the lines here
649 #define wxStrdup wxStrdupW
651 #define wxStrdup wxStrdupA
654 WXDLLEXPORT
bool wxOKlibc(); // for internal use
656 // ----------------------------------------------------------------------------
657 // printf() family saga
658 // ----------------------------------------------------------------------------
661 For some systems vsnprintf() exists in the system libraries but not in the
662 headers, so we need to declare it ourselves to be able to use it.
664 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
666 int vsnprintf(char *str
, size_t size
, const char *format
, va_list ap
);
667 #endif // !HAVE_VSNPRINTF_DECL
670 First of all, we always want to define safe snprintf() function to be used
671 instead of sprintf(). Some compilers already have it (or rather vsnprintf()
672 which we really need...), otherwise we implement it using our own printf()
675 We define function with a trailing underscore here because the real one is a
676 wrapper around it as explained below
680 #if defined(HAVE__VSNWPRINTF)
681 #define wxVsnprintf_ _vsnwprintf
682 /* MinGW?MSVCRT has the wrong vswprintf */
683 #elif defined(HAVE_VSWPRINTF) && !defined(__MINGW32__)
684 #define wxVsnprintf_ vswprintf
687 // all versions of CodeWarrior supported by wxWindows apparently have
689 #if defined(HAVE_VSNPRINTF) || defined(__MWERKS__)
690 // assume we have snprintf() too if we have vsnprintf()
691 #define wxVsnprintf_ vsnprintf
692 #define wxSnprintf_ snprintf
695 #endif // wxVsnprintf_ not defined yet
698 // no [v]snprintf(), cook our own
699 WXDLLEXPORT
int wxSnprintf_(wxChar
*buf
, size_t len
, const wxChar
*format
,
700 ...) ATTRIBUTE_PRINTF_3
;
703 WXDLLEXPORT
int wxVsnprintf_(wxChar
*buf
, size_t len
, const wxChar
*format
,
708 In Unicode mode we need to have all standard functions such as wprintf() and
709 so on but not all systems have them so use our own implementations in this
712 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
713 #define wxNEED_WPRINTF
717 More Unicode complications: although both ANSI C and C++ define a number of
718 wide character functions such as wprintf(), not all environments have them.
719 Worse, those which do have different behaviours: under Windows, %s format
720 specifier changes its meaning in Unicode build and expects a Unicode string
721 while under Unix/POSIX it still means an ASCII string even for wprintf() and
722 %ls has to be used for wide strings.
724 We choose to always emulate Windows behaviour as more useful for us so even
725 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
727 However, if we don't have any vswprintf() at all we don't need to redefine
728 anything as our own wxVsnprintf_() already behaves as needed.
731 #undef wxNEED_PRINTF_CONVERSION
734 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
735 // we need to implement all wide character printf and scanf functions
736 // either because we don't have them at all or because they don't have the
739 #include <stdio.h> // for FILE
741 int wxScanf( const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_1
;
742 int wxSscanf( const wxChar
*str
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
743 int wxFscanf( FILE *stream
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
744 int wxVsscanf( const wxChar
*str
, const wxChar
*format
, va_list ap
);
745 int wxPrintf( const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_1
;
746 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
747 int wxFprintf( FILE *stream
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_2
;
748 int wxVfprintf( FILE *stream
, const wxChar
*format
, va_list ap
);
749 int wxVprintf( const wxChar
*format
, va_list ap
);
750 int wxVsprintf( wxChar
*str
, const wxChar
*format
, va_list ap
);
751 #endif // wxNEED_PRINTF_CONVERSION
753 // these 2 can be simply mapped to the versions with underscore at the end
754 // if we don't have to do the conversion
755 #ifdef wxNEED_PRINTF_CONVERSION
756 int wxSnprintf( wxChar
*str
, size_t size
, const wxChar
*format
, ... ) ATTRIBUTE_PRINTF_3
;
757 int wxVsnprintf( wxChar
*str
, size_t size
, const wxChar
*format
, va_list ap
);
759 #define wxSnprintf wxSnprintf_
760 #define wxVsnprintf wxVsnprintf_
763 // ----------------------------------------------------------------------------
764 // various functions which might not be available in libc and for which we
765 // provide our own replacements in wxchar.cpp
766 // ----------------------------------------------------------------------------
770 // VZ: note that this is never defined currently
771 #ifdef wxNEED_WX_CTYPE_H
772 WXDLLEXPORT
int wxIsalnum(wxChar ch
);
773 WXDLLEXPORT
int wxIsalpha(wxChar ch
);
774 WXDLLEXPORT
int wxIsctrl(wxChar ch
);
775 WXDLLEXPORT
int wxIsdigit(wxChar ch
);
776 WXDLLEXPORT
int wxIsgraph(wxChar ch
);
777 WXDLLEXPORT
int wxIslower(wxChar ch
);
778 WXDLLEXPORT
int wxIsprint(wxChar ch
);
779 WXDLLEXPORT
int wxIspunct(wxChar ch
);
780 WXDLLEXPORT
int wxIsspace(wxChar ch
);
781 WXDLLEXPORT
int wxIsupper(wxChar ch
);
782 WXDLLEXPORT
int wxIsxdigit(wxChar ch
);
783 WXDLLEXPORT
int wxTolower(wxChar ch
);
784 WXDLLEXPORT
int wxToupper(wxChar ch
);
785 #endif // wxNEED_WX_CTYPE_H
787 // under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks
788 // the file parsing -- this may be true for 5.0 as well, update #ifdef then
789 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
791 #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
795 // string.h functions
797 // VZ: this is never defined neither currently
798 #ifdef wxNEED_WX_STRING_H
799 WXDLLEXPORT wxChar
* wxStrcat(wxChar
*dest
, const wxChar
*src
);
800 WXDLLEXPORT
const wxChar
* wxStrchr(const wxChar
*s
, wxChar c
);
801 WXDLLEXPORT wxChar
* wxStrchr(wxChar
*s
, wxChar c
)
802 { return (wxChar
*)wxStrchr((const wxChar
*)s
, c
); }
803 WXDLLEXPORT
int wxStrcmp(const wxChar
*s1
, const wxChar
*s2
);
804 WXDLLEXPORT
int wxStrcoll(const wxChar
*s1
, const wxChar
*s2
);
805 WXDLLEXPORT wxChar
* wxStrcpy(wxChar
*dest
, const wxChar
*src
);
806 WXDLLEXPORT
size_t wxStrcspn(const wxChar
*s
, const wxChar
*reject
);
807 WXDLLEXPORT
size_t wxStrlen(const wxChar
*s
);
808 WXDLLEXPORT wxChar
* wxStrncat(wxChar
*dest
, const wxChar
*src
, size_t n
);
809 WXDLLEXPORT
int wxStrncmp(const wxChar
*s1
, const wxChar
*s2
, size_t n
);
810 WXDLLEXPORT wxChar
* wxStrncpy(wxChar
*dest
, const wxChar
*src
, size_t n
);
811 WXDLLEXPORT
const wxChar
* wxStrpbrk(const wxChar
*s
, const wxChar
*accept
);
812 WXDLLEXPORT wxChar
* wxStrpbrk(wxChar
*s
, const wxChar
*accept
)
813 { return (wxChar
*)wxStrpbrk((const wxChar
*)s
, accept
); }
814 WXDLLEXPORT
const wxChar
* wxStrrchr(const wxChar
*s
, wxChar c
);
815 WXDLLEXPORT wxChar
* wxStrrchr(wxChar
*s
, wxChar c
)
816 { return (wxChar
*)wxStrrchr((const wxChar
*)s
, c
); }
817 WXDLLEXPORT
size_t wxStrspn(const wxChar
*s
, const wxChar
*accept
);
818 WXDLLEXPORT
const wxChar
* wxStrstr(const wxChar
*haystack
, const wxChar
*needle
);
819 WXDLLEXPORT wxChar
*wxStrstr(wxChar
*haystack
, const wxChar
*needle
)
820 { return (wxChar
*)wxStrstr((const wxChar
*)haystack
, needle
); }
821 WXDLLEXPORT
double wxStrtod(const wxChar
*nptr
, wxChar
**endptr
);
822 WXDLLEXPORT
long int wxStrtol(const wxChar
*nptr
, wxChar
**endptr
, int base
);
823 WXDLLEXPORT
unsigned long int wxStrtoul(const wxChar
*nptr
, wxChar
**endptr
, int base
);
824 WXDLLEXPORT
size_t wxStrxfrm(wxChar
*dest
, const wxChar
*src
, size_t n
);
825 #endif // wxNEED_WX_STRING_H
828 WXDLLEXPORT
char *wxStrdupA(const char *psz
);
832 WXDLLEXPORT
wchar_t *wxStrdupW(const wchar_t *pwz
);
836 WXDLLEXPORT
int wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
);
840 WXDLLEXPORT
int wxStrnicmp(const wxChar
*psz1
, const wxChar
*psz2
, size_t len
);
844 WXDLLEXPORT wxChar
* wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
848 class WXDLLEXPORT wxWCharBuffer
;
849 WXDLLEXPORT wxWCharBuffer
wxSetlocale(int category
, const wxChar
*locale
);
853 #ifdef wxNEED_WX_STDIO_H
855 WXDLLEXPORT
FILE * wxFopen(const wxChar
*path
, const wxChar
*mode
);
856 WXDLLEXPORT
FILE * wxFreopen(const wxChar
*path
, const wxChar
*mode
, FILE *stream
);
857 WXDLLEXPORT
int wxRemove(const wxChar
*path
);
858 WXDLLEXPORT
int wxRename(const wxChar
*oldpath
, const wxChar
*newpath
);
860 // *printf() family is handled separately
861 #endif // wxNEED_WX_STDIO_H
864 // stdlib.h functions
866 WXDLLEXPORT
double wxAtof(const wxChar
*psz
);
869 #ifdef wxNEED_WX_STDLIB_H
870 WXDLLEXPORT
int wxAtoi(const wxChar
*psz
);
871 WXDLLEXPORT
long wxAtol(const wxChar
*psz
);
872 WXDLLEXPORT wxChar
* wxGetenv(const wxChar
*name
);
873 WXDLLEXPORT
int wxSystem(const wxChar
*psz
);
878 #ifdef wxNEED_WX_TIME_H
879 #if defined(__MWERKS__) && defined(macintosh)
882 WXDLLEXPORT
size_t wxStrftime(wxChar
*s
, size_t max
,
883 const wxChar
*fmt
, const struct tm
*tm
);
884 #endif // wxNEED_WX_TIME_H
886 // ----------------------------------------------------------------------------
887 // multibyte to wide char conversion functions and macros
888 // ----------------------------------------------------------------------------
891 // multibyte<->widechar conversion
892 WXDLLEXPORT
size_t wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
893 WXDLLEXPORT
size_t wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
896 #define wxMB2WX wxMB2WC
897 #define wxWX2MB wxWC2MB
898 #define wxWC2WX wxStrncpy
899 #define wxWX2WC wxStrncpy
901 #define wxMB2WX wxStrncpy
902 #define wxWX2MB wxStrncpy
903 #define wxWC2WX wxWC2MB
904 #define wxWX2WC wxMB2WC
906 #else // !wxUSE_UNICODE
907 // No wxUSE_WCHAR_T: we have to do something (JACS)
908 #define wxMB2WC wxStrncpy
909 #define wxWC2MB wxStrncpy
910 #define wxMB2WX wxStrncpy
911 #define wxWX2MB wxStrncpy
912 #define wxWC2WX wxWC2MB
913 #define wxWX2WC wxMB2WC
916 #endif //_WX_WXCHAR_H_