3 * Purpose: Type-safe ANSI and Unicode builds compatible wrappers for
5 * Author: Joel Farley, Ove Kåven
6 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
9 * Copyright: (c) 1998-2006 wxWidgets dev team
10 * Licence: wxWindows licence
13 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
18 #include "wx/chartype.h"
20 #include <stdio.h> /* we use FILE below */
22 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
23 char *strtok_r(char *, const char *, char **);
28 Standard headers we need here.
30 NB: don't include any wxWidgets headers here because almost all of them include
34 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
35 /* and VC++ for Windows CE don't provide it */
36 #if defined(__VISUALC__) && __VISUALC__ >= 1400
37 #define wxStrdupA _strdup
38 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
39 /* use #define, not inline wrapper, as it is tested with #ifndef below */
40 #define wxStrdupA strdup
43 #if defined(__MWERKS__)
44 /* Metrowerks only has wide char support for OS X >= 10.3 */
45 #if !defined(__DARWIN__) || \
46 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
47 #define wxHAVE_MWERKS_UNICODE
50 #ifdef wxHAVE_MWERKS_UNICODE
51 #define HAVE_WPRINTF 1
52 #define HAVE_WCSRTOMBS 1
53 #define HAVE_VSWPRINTF 1
55 #endif /* __MWERKS__ */
57 #ifdef wxHAVE_TCHAR_SUPPORT
58 /* we surely have wchar_t if we have TCHAR have wcslen() */
62 #endif /* wxHAVE_TCHAR_SUPPORT */
65 define wxFoo() function for each standard foo() function whose signature
66 (exceptionally including the return type) includes any mention of char:
67 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
68 the same signature but with char replaced by wxChar which allows us to
69 use it in Unicode build as well
72 #ifdef wxHAVE_TCHAR_SUPPORT
75 #if defined(__WATCOMC__) && defined(UNICODE)
76 #define WXWCHAR_T_CAST(c) (wint_t)(c)
78 #define WXWCHAR_T_CAST(c) c
81 /* ctype.h functions */
82 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
83 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
84 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
85 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
86 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
87 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
88 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
89 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
90 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
91 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
92 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
95 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
96 signed chars < 0, so "fix" it here.
98 #define wxTolower(c) _totlower((wxUChar)(wxChar)(c))
99 #define wxToupper(c) _totupper((wxUChar)(wxChar)(c))
101 /* locale.h functons */
102 #define wxSetlocale _tsetlocale
104 /* string.h functions */
105 #define wxStrcat _tcscat
106 #define wxStrchr _tcschr
107 #define wxStrcmp _tcscmp
108 #define wxStrcoll _tcscoll
109 #define wxStrcpy _tcscpy
110 #define wxStrcspn _tcscspn
111 #define wxStrdupW _wcsdup /* notice the 'W'! */
112 #define wxStrftime _tcsftime
113 #define wxStricmp _tcsicmp
114 #define wxStrnicmp _tcsnicmp
115 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
116 #define wxStrncat _tcsncat
117 #define wxStrncmp _tcsncmp
118 #define wxStrncpy _tcsncpy
119 #define wxStrpbrk _tcspbrk
120 #define wxStrrchr _tcsrchr
121 #define wxStrspn _tcsspn
122 #define wxStrstr _tcsstr
123 #define wxStrtod _tcstod
124 #define wxStrtol _tcstol
125 #define wxStrtoul _tcstoul
127 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
128 #define wxStrtoll _tcstoi64
129 #define wxStrtoull _tcstoui64
132 #define wxStrxfrm _tcsxfrm
134 /* stdio.h functions */
135 #define wxFgetc _fgettc
136 #define wxFgetchar _fgettchar
137 #define wxFgets _fgetts
138 #if wxUSE_UNICODE_MSLU
139 WXDLLIMPEXP_BASE
FILE * wxMSLU__tfopen(const wxChar
*name
, const wxChar
*mode
);
141 #define wxFopen wxMSLU__tfopen
143 #define wxFopen _tfopen
145 #define wxFputc _fputtc
146 #define wxFputchar _fputtchar
147 #define wxFputs _fputts
148 #define wxFreopen _tfreopen
149 #define wxGetc _gettc
150 #define wxGetchar _gettchar
151 #define wxGets _getts
152 #define wxPerror _tperror
153 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
154 #define wxPutchar _puttchar
155 #define wxPuts _putts
157 #define wxTmpnam _ttmpnam
158 #define wxUngetc _tungetc
160 /* special case: these functions are missing under Win9x with Unicows so we */
161 /* have to implement them ourselves */
162 #if wxUSE_UNICODE_MSLU
163 WXDLLIMPEXP_BASE
int wxMSLU__trename(const wxChar
*oldname
, const wxChar
*newname
);
164 WXDLLIMPEXP_BASE
int wxMSLU__tremove(const wxChar
*name
);
166 #define wxRemove wxMSLU__tremove
167 #define wxRename wxMSLU__trename
170 /* carefully: wxRemove() must return 0 on success while DeleteFile()
171 returns 0 on error, so don't just define one as the other */
172 int wxRemove(const wxChar
*path
);
174 #define wxRemove _tremove
175 #define wxRename _trename
179 /* stdlib.h functions */
182 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
183 /* there are no env vars at all under CE, so no _tgetenv neither */
185 /* can't define as inline function as this is a C file... */
186 #define wxGetenv(name) ((wxChar *)NULL)
188 #define wxGetenv _tgetenv
190 #define wxSystem _tsystem
192 /* time.h functions */
193 #define wxAsctime _tasctime
194 #define wxCtime _tctime
196 #define wxMbstowcs mbstowcs
197 #define wxWcstombs wcstombs
198 #else /* !TCHAR-aware compilers */
200 There are 2 unrelated problems with these functions under Mac:
201 a) Metrowerks MSL CRT implements them strictly in C99 sense and
202 doesn't support (very common) extension of allowing to call
203 mbstowcs(NULL, ...) which makes it pretty useless as you can't
204 know the size of the needed buffer
205 b) OS X <= 10.2 declares and even defined these functions but
206 doesn't really implement them -- they always return an error
208 So use our own replacements in both cases.
210 #if defined(__MWERKS__) && defined(__MSL__)
211 #define wxNEED_WX_MBSTOWCS
215 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
216 #define wxNEED_WX_MBSTOWCS
220 #ifdef wxNEED_WX_MBSTOWCS
221 /* even though they are defined and "implemented", they are bad and just
222 stubs so we need our own - we need these even in ANSI builds!! */
223 WXDLLIMPEXP_BASE
size_t wxMbstowcs (wchar_t *, const char *, size_t);
224 WXDLLIMPEXP_BASE
size_t wxWcstombs (char *, const wchar_t *, size_t);
226 #define wxMbstowcs mbstowcs
227 #define wxWcstombs wcstombs
231 The system C library on Mac OS X 10.2 and below does not support
232 unicode: in other words all wide-character functions such as towupper et
233 al. do simply not exist so we need to provide our own in that context,
234 except for the wchar_t definition/typedef itself.
236 We need to do this for both project builder and CodeWarrior as
237 the latter uses the system C library in Mach builds for wide character
238 support, which as mentioned does not exist on 10.2 and below.
240 #if wxUSE_UNICODE && \
241 defined(__DARWIN__) && \
242 ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
243 /* we need everything! */
244 #define wxNEED_WX_STRING_H
245 #define wxNEED_WX_CTYPE_H
247 #define wxFgetchar(c) wxFgetc(c, stdin)
248 #define wxFputc wxPutc
249 #define wxFputchar(c) wxPutc(c, stdout)
250 #define wxGetc wxFgetc
251 #define wxGetchar(c) wxFgetc(c, stdin)
258 #define wxNEED_UNGETC
264 int wxFputs(const wxChar
*ch
, FILE *stream
);
265 int wxPuts(const wxChar
*ws
);
266 int wxPutc(wxChar ch
, FILE *stream
);
271 WXDLLIMPEXP_BASE
size_t wxStrlen_(const wxChar
*s
);
276 #define wxPutchar(wch) wxPutc(wch, stdout)
278 #define wxNEED_PRINTF_CONVERSION
279 #define wxNEED_WX_STDIO_H
280 #define wxNEED_WX_STDLIB_H
281 #define wxNEED_WX_TIME_H
286 /* this is probably glibc-specific */
287 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
288 /* ctype.h functions (wctype.h) */
289 #define wxIsalnum iswalnum
290 #define wxIsalpha iswalpha
291 #define wxIscntrl iswcntrl
292 #define wxIsdigit iswdigit
293 #define wxIsgraph iswgraph
294 #define wxIslower iswlower
295 #define wxIsprint iswprint
296 #define wxIspunct iswpunct
297 #define wxIsspace iswspace
298 #define wxIsupper iswupper
299 #define wxIsxdigit iswxdigit
301 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
302 /* /usr/include/wctype.h incorrectly declares translations */
303 /* tables which provokes tons of compile-time warnings -- try */
304 /* to correct this */
305 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
306 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
307 #else /* !glibc 2.0 */
308 #define wxTolower towlower
309 #define wxToupper towupper
310 #endif /* gcc/!gcc */
312 /* string.h functions (wchar.h) */
313 #define wxStrcat wcscat
314 #define wxStrchr wcschr
315 #define wxStrcmp wcscmp
316 #define wxStrcoll wcscoll
317 #define wxStrcpy wcscpy
318 #define wxStrcspn wcscspn
319 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
320 #define wxStrncat wcsncat
321 #define wxStrncmp wcsncmp
322 #define wxStrncpy wcsncpy
323 #define wxStrpbrk wcspbrk
324 #define wxStrrchr wcsrchr
325 #define wxStrspn wcsspn
326 #define wxStrstr wcsstr
327 #define wxStrtod wcstod
328 #define wxStrtol wcstol
329 #define wxStrtoul wcstoul
331 /* assume that we have wcstoull(), which is also C99, too */
332 #define wxStrtoll wcstoll
333 #define wxStrtoull wcstoull
334 #endif /* HAVE_WCSTOULL */
335 #define wxStrxfrm wcsxfrm
337 #define wxFgetc fgetwc
338 #define wxFgetchar fgetwchar
339 #define wxFgets fgetws
340 #define wxFputc fputwc
341 #define wxFputchar fputwchar
343 #define wxGetchar getwchar
345 #define wxUngetc ungetwc
348 #define wxFputs fputws
352 int wxFputs(const wxChar
*ch
, FILE *stream
);
360 int wxPutc(wxChar ch
, FILE *stream
);
364 #define wxPutchar wputchar
366 #define wxPutchar(wch) wxPutc(wch, stdout)
373 int wxPuts(const wxChar
*ws
);
376 /* we need %s to %ls conversion for printf and scanf etc */
377 #define wxNEED_PRINTF_CONVERSION
379 /* glibc doesn't have wide char equivalents of the other stuff so */
380 /* use our own versions */
381 #define wxNEED_WX_STDIO_H
382 #define wxNEED_WX_STDLIB_H
383 #define wxNEED_WX_TIME_H
384 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
385 /* ctype.h functions (wctype.h) */
386 #define wxIsalnum iswalnum
387 #define wxIsalpha iswalpha
388 #define wxIscntrl iswcntrl
389 #define wxIsdigit iswdigit
390 #define wxIsgraph iswgraph
391 #define wxIslower iswlower
392 #define wxIsprint iswprint
393 #define wxIspunct iswpunct
394 #define wxIsspace iswspace
395 #define wxIsupper iswupper
396 #define wxIsxdigit iswxdigit
397 #define wxTolower towlower
398 #define wxToupper towupper
400 /* string.h functions (wchar.h) */
401 #define wxStrcat wcscat
402 #define wxStrchr wcschr
403 #define wxStrcmp wcscmp
404 #define wxStrcoll wcscoll
405 #define wxStrcpy wcscpy
406 #define wxStrcspn wcscspn
407 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
408 #define wxStrncat wcsncat
409 #define wxStrncmp wcsncmp
410 #define wxStrncpy wcsncpy
411 #define wxStrpbrk wcspbrk
412 #define wxStrrchr wcsrchr
413 #define wxStrspn wcsspn
414 #define wxStrstr wcsstr
415 #define wxStrtod wcstod
416 #define wxStrtol wcstol
417 #define wxStrtoul wcstoul
418 #define wxStrxfrm wcsxfrm
420 #define wxFgetc fgetwc
421 #define wxFgetchar fgetwchar
422 #define wxFgets fgetws
423 #define wxFputc fputwc
424 #define wxFputchar fputwchar
426 #define wxGetchar getwchar
428 #define wxUngetc ungetwc
430 #define wxNEED_PRINTF_CONVERSION
433 #define wxPutchar putwchar
434 #define wxFputs fputws
436 /* stdio.h functions */
438 #define wxNEED_WX_STDIO_H
440 /* stdlib.h functions */
442 #define wxNEED_WX_STDLIB_H
447 #define wxGetenv(a) ((wxChar*)NULL)
448 #define wxSystem(a) ((int)NULL)
450 /* time.h functions */
451 #define wxAsctime wasciitime
452 #define wxCtime wctime
453 /* #define wxStrftime wcsftime */
455 #define wxNEED_WX_TIME_H
456 #else /* !metrowerks for apple */
457 #error "Please define wide character functions for your environment"
463 /* ctype.h functions */
464 #define wxIsalnum isalnum
465 #define wxIsalpha isalpha
466 #define wxIscntrl iscntrl
467 #define wxIsdigit isdigit
468 #define wxIsgraph isgraph
469 #define wxIslower islower
470 #define wxIsprint isprint
471 #define wxIspunct ispunct
472 #define wxIsspace isspace
473 #define wxIsupper isupper
474 #define wxIsxdigit isxdigit
475 #define wxTolower tolower
476 #define wxToupper toupper
478 /* locale.h functons */
479 #define wxSetlocale setlocale
481 /* string.h functions */
482 #define wxStrcat strcat
483 #define wxStrchr strchr
484 #define wxStrcmp strcmp
485 #define wxStrcoll strcoll
486 #define wxStrcpy strcpy
487 #define wxStrcspn strcspn
489 /* wxStricmp and wxStrnicmp are defined below */
490 #define wxStrlen_ strlen /* used in wxStrlen inline function */
491 #define wxStrncat strncat
492 #define wxStrncmp strncmp
493 #define wxStrncpy strncpy
494 #define wxStrpbrk strpbrk
495 #define wxStrrchr strrchr
496 #define wxStrspn strspn
497 #define wxStrstr strstr
498 #define wxStrtod strtod
500 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
502 #define wxStrtol strtol
503 #define wxStrtoul strtoul
505 /* assume that we have wcstoull(), which is also C99, too */
506 #define wxStrtoll strtoll
507 #define wxStrtoull strtoull
508 #endif /* HAVE_WCSTOULL */
509 #define wxStrxfrm strxfrm
511 /* stdio.h functions */
512 #define wxFopen fopen
513 #define wxFreopen freopen
514 #define wxRemove remove
515 #define wxRename rename
517 #define wxPerror perror
518 #define wxTmpnam tmpnam
520 #define wxFgetc fgetc
521 #define wxFgetchar fgetchar
522 #define wxFgets fgets
523 #define wxFputc fputc
524 #define wxFputs fputs
525 #define wxFputchar fputchar
527 #define wxGetchar getchar
530 #define wxPutchar putchar
532 #define wxUngetc ungetc
534 /* stdlib.h functions */
538 #define wxGetenv getenv
539 #define wxSystem system
541 /* time.h functions */
542 #define wxAsctime asctime
543 #define wxCtime ctime
544 #define wxStrftime strftime
545 #endif /* Unicode/ASCII */
546 #endif /* TCHAR-aware compilers/the others */
549 various special cases
552 /* define wxStricmp and wxStrnicmp for various compilers */
554 /* note that in Unicode mode we definitely are going to need our own version */
555 #if !defined(wxStricmp) && !wxUSE_UNICODE
556 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
557 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
558 defined(__EMX__) || defined(__DJGPP__)
559 #define wxStricmp stricmp
560 #define wxStrnicmp strnicmp
561 #elif defined(__WXPALMOS__)
562 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
563 * quick hack should do until one can be written.
565 #define wxStricmp StrCaselessCompare
566 #define wxStrnicmp strnicmp
567 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
568 (defined(__MWERKS__) && defined(__INTEL__))
569 #define wxStricmp _stricmp
570 #define wxStrnicmp _strnicmp
571 #elif defined(__UNIX__) || defined(__GNUWIN32__)
572 #define wxStricmp strcasecmp
573 #define wxStrnicmp strncasecmp
574 /* #else -- use wxWidgets implementation */
576 #endif /* !defined(wxStricmp) */
578 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
579 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
580 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
583 #define wxWcslen wcslen
585 WXDLLIMPEXP_BASE
size_t wxWcslen(const wchar_t *s
);
587 #endif /* wxUSE_WCHAR_T */
590 /* checks whether the passed in pointer is NULL and if the string is empty */
591 inline bool wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
593 /* safe version of strlen() (returns 0 if passed NULL pointer) */
594 inline size_t wxStrlen(const wxChar
*psz
) { return psz
? wxStrlen_(psz
) : 0; }
598 each of strdup() and wcsdup() may or may not be available but we need both
599 of them anyhow for wx/buffer.h so we define the missing one(s) in
600 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
601 defined -- if this is somehow not the case in some situations, please
602 correct that and not the lines here
605 #define wxStrdup wxStrdupW
607 #define wxStrdup wxStrdupA
611 WXDLLIMPEXP_BASE
bool wxOKlibc(); /* for internal use */
615 /* supply strtoll and strtoull, if needed */
616 WXDLLIMPEXP_BASE wxLongLong_t
wxStrtoll(const wxChar
* nptr
, wxChar
** endptr
, int base
);
617 WXDLLIMPEXP_BASE wxULongLong_t
wxStrtoull(const wxChar
* nptr
, wxChar
** endptr
, int base
);
620 #define wxHAS_STRTOLL
623 In Unicode mode we need to have all standard functions such as wprintf() and
624 so on but not all systems have them so use our own implementations in this
627 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
628 #define wxNEED_WPRINTF
632 various functions which might not be available in libc and for which we
633 provide our own replacements in wxchar.cpp
636 /* ctype.h functions */
638 /* RN: Used only under OSX <= 10.2 currently */
639 #ifdef wxNEED_WX_CTYPE_H
640 WXDLLIMPEXP_BASE
int wxIsalnum(wxChar ch
);
641 WXDLLIMPEXP_BASE
int wxIsalpha(wxChar ch
);
642 WXDLLIMPEXP_BASE
int wxIscntrl(wxChar ch
);
643 WXDLLIMPEXP_BASE
int wxIsdigit(wxChar ch
);
644 WXDLLIMPEXP_BASE
int wxIsgraph(wxChar ch
);
645 WXDLLIMPEXP_BASE
int wxIslower(wxChar ch
);
646 WXDLLIMPEXP_BASE
int wxIsprint(wxChar ch
);
647 WXDLLIMPEXP_BASE
int wxIspunct(wxChar ch
);
648 WXDLLIMPEXP_BASE
int wxIsspace(wxChar ch
);
649 WXDLLIMPEXP_BASE
int wxIsupper(wxChar ch
);
650 WXDLLIMPEXP_BASE
int wxIsxdigit(wxChar ch
);
651 WXDLLIMPEXP_BASE
int wxTolower(wxChar ch
);
652 WXDLLIMPEXP_BASE
int wxToupper(wxChar ch
);
653 #endif /* wxNEED_WX_CTYPE_H */
655 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
656 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
657 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
659 #define wxIsspace(c) ((((unsigned)(wxChar)c) < 128) && isspace(c))
663 a few compilers don't have the (non standard but common) isascii function,
664 define it ourselves for them
667 #if defined(__MWERKS__)
668 #define wxNEED_ISASCII
669 #elif defined(_WIN32_WCE)
670 #if _WIN32_WCE <= 211
671 #define wxNEED_ISASCII
676 #ifdef wxNEED_ISASCII
677 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
681 #if _WIN32_WCE <= 211
682 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
684 #endif /* _WIN32_WCE */
687 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
688 initial versions of this header -- now it is too late to remove it so
689 although we fixed the function/macro name above, still provide the
690 backwards-compatible synonym.
692 #define wxIsctrl wxIscntrl
694 /* string.h functions */
696 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
697 #define wxNEED_STRDUP
698 #elif defined(__WXWINCE__)
699 #if _WIN32_WCE <= 211
700 #define wxNEED_STRDUP
706 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
709 /* RN: Used only under OSX <= 10.2 currently
710 The __cplusplus ifdefs are messy, but they are required to build
711 the regex library, since c does not support function overloading
713 #ifdef wxNEED_WX_STRING_H
717 WXDLLIMPEXP_BASE wxChar
* wxStrcat(wxChar
*dest
, const wxChar
*src
);
718 WXDLLIMPEXP_BASE
const wxChar
* wxStrchr(const wxChar
*s
, wxChar c
);
719 WXDLLIMPEXP_BASE
int wxStrcmp(const wxChar
*s1
, const wxChar
*s2
);
720 WXDLLIMPEXP_BASE
int wxStrcoll(const wxChar
*s1
, const wxChar
*s2
);
721 WXDLLIMPEXP_BASE wxChar
* wxStrcpy(wxChar
*dest
, const wxChar
*src
);
722 WXDLLIMPEXP_BASE
size_t wxStrcspn(const wxChar
*s
, const wxChar
*reject
);
723 WXDLLIMPEXP_BASE wxChar
* wxStrncat(wxChar
*dest
, const wxChar
*src
, size_t n
);
724 WXDLLIMPEXP_BASE
int wxStrncmp(const wxChar
*s1
, const wxChar
*s2
, size_t n
);
725 WXDLLIMPEXP_BASE wxChar
* wxStrncpy(wxChar
*dest
, const wxChar
*src
, size_t n
);
726 WXDLLIMPEXP_BASE
const wxChar
* wxStrpbrk(const wxChar
*s
, const wxChar
*accept
);
727 WXDLLIMPEXP_BASE
const wxChar
* wxStrrchr(const wxChar
*s
, wxChar c
);
728 WXDLLIMPEXP_BASE
size_t wxStrspn(const wxChar
*s
, const wxChar
*accept
);
729 WXDLLIMPEXP_BASE
const wxChar
* wxStrstr(const wxChar
*haystack
, const wxChar
*needle
);
734 /* These functions use C++, so we can't c extern them */
735 WXDLLIMPEXP_BASE
double wxStrtod(const wxChar
*nptr
, wxChar
**endptr
);
736 WXDLLIMPEXP_BASE
long int wxStrtol(const wxChar
*nptr
, wxChar
**endptr
, int base
);
737 WXDLLIMPEXP_BASE
unsigned long int wxStrtoul(const wxChar
*nptr
, wxChar
**endptr
, int base
);
738 WXDLLIMPEXP_BASE
size_t wxStrxfrm(wxChar
*dest
, const wxChar
*src
, size_t n
);
740 /* inlined versions */
742 inline wxChar
* wxStrchr(wxChar
*s
, wxChar c
)
743 { return (wxChar
*)wxStrchr((const wxChar
*)s
, c
); }
744 inline wxChar
* wxStrpbrk(wxChar
*s
, const wxChar
*accept
)
745 { return (wxChar
*)wxStrpbrk((const wxChar
*)s
, accept
); }
746 inline wxChar
* wxStrrchr(wxChar
*s
, wxChar c
)
747 { return (wxChar
*)wxStrrchr((const wxChar
*)s
, c
); }
748 inline wxChar
*wxStrstr(wxChar
*haystack
, const wxChar
*needle
)
749 { return (wxChar
*)wxStrstr((const wxChar
*)haystack
, needle
); }
752 #endif /* wxNEED_WX_STRING_H */
755 WXDLLIMPEXP_BASE
char *wxStrdupA(const char *psz
);
759 WXDLLIMPEXP_BASE
wchar_t *wxStrdupW(const wchar_t *pwz
);
763 WXDLLIMPEXP_BASE
int wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
);
767 WXDLLIMPEXP_BASE
int wxStrnicmp(const wxChar
*psz1
, const wxChar
*psz2
, size_t len
);
771 WXDLLIMPEXP_BASE wxChar
* wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
776 class WXDLLIMPEXP_BASE wxWCharBuffer
;
777 WXDLLIMPEXP_BASE wxWCharBuffer
wxSetlocale(int category
, const wxChar
*locale
);
781 /* stdio.h functions */
782 #ifdef wxNEED_WX_STDIO_H
784 WXDLLIMPEXP_BASE
FILE * wxFopen(const wxChar
*path
, const wxChar
*mode
);
785 WXDLLIMPEXP_BASE
FILE * wxFreopen(const wxChar
*path
, const wxChar
*mode
, FILE *stream
);
786 WXDLLIMPEXP_BASE
int wxRemove(const wxChar
*path
);
787 WXDLLIMPEXP_BASE
int wxRename(const wxChar
*oldpath
, const wxChar
*newpath
);
789 /* *printf() family is handled separately */
790 #endif /* wxNEED_WX_STDIO_H */
793 /* stdlib.h functions */
795 WXDLLIMPEXP_BASE
double wxAtof(const wxChar
*psz
);
798 #ifdef wxNEED_WX_STDLIB_H
799 WXDLLIMPEXP_BASE
int wxAtoi(const wxChar
*psz
);
800 WXDLLIMPEXP_BASE
long wxAtol(const wxChar
*psz
);
801 WXDLLIMPEXP_BASE wxChar
* wxGetenv(const wxChar
*name
);
802 WXDLLIMPEXP_BASE
int wxSystem(const wxChar
*psz
);
806 /* time.h functions */
807 #ifdef wxNEED_WX_TIME_H
808 #if defined(__MWERKS__) && defined(macintosh)
811 /*silent gabby compilers*/
813 WXDLLIMPEXP_BASE
size_t wxStrftime(wxChar
*s
, size_t max
,
815 const struct tm
*tm
);
816 #endif /* wxNEED_WX_TIME_H */
820 WXDLLIMPEXP_BASE wxChar
*wxCtime(const time_t *timep
);
824 /* missing functions in some WinCE versions */
826 #if (_WIN32_WCE < 300)
827 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
829 #endif /* _WIN32_WCE */
831 /* multibyte to wide char conversion functions and macros */
834 /* multibyte<->widechar conversion */
835 WXDLLIMPEXP_BASE
size_t wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
836 WXDLLIMPEXP_BASE
size_t wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
839 #define wxMB2WX wxMB2WC
840 #define wxWX2MB wxWC2MB
841 #define wxWC2WX wxStrncpy
842 #define wxWX2WC wxStrncpy
844 #define wxMB2WX wxStrncpy
845 #define wxWX2MB wxStrncpy
846 #define wxWC2WX wxWC2MB
847 #define wxWX2WC wxMB2WC
849 #else /* !wxUSE_UNICODE */
852 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
853 #define wxMB2WC wxStrncpy
854 #define wxWC2MB wxStrncpy
855 #define wxMB2WX wxStrncpy
856 #define wxWX2MB wxStrncpy
857 #define wxWC2WX wxWC2MB
858 #define wxWX2WC wxMB2WC
862 RN: The following are not normal versions of memcpy et al., rather
863 these are either char or widechar versions depending on
864 if unicode is used or not.
870 // RN: We could do the usual tricky compiler detection here,
871 // and use their variant (such as wmemchr, etc.). The problem
872 // is that these functions are quite rare, even though they are
873 // part of the current POSIX standard. In addition, most compilers
874 // (including even MSC) inline them just like we do right in their
878 #include <string.h> //for mem funcs
880 //implement our own wmem variants
881 inline wxChar
* wxTmemchr(const wxChar
* s
, wxChar c
, size_t l
)
883 for(;l
&& *s
!= c
;--l
, ++s
) {}
890 inline int wxTmemcmp(const wxChar
* sz1
, const wxChar
* sz2
, size_t len
)
892 for(; *sz1
== *sz2
&& len
; --len
, ++sz1
, ++sz2
) {}
895 return *sz1
< *sz2
? -1 : *sz1
> *sz2
;
900 inline wxChar
* wxTmemcpy(wxChar
* szOut
, const wxChar
* szIn
, size_t len
)
902 return (wxChar
*) memcpy(szOut
, szIn
, len
* sizeof(wxChar
));
905 inline wxChar
* wxTmemmove(wxChar
* szOut
, const wxChar
* szIn
, size_t len
)
907 return (wxChar
*) memmove(szOut
, szIn
, len
* sizeof(wxChar
));
910 inline wxChar
* wxTmemset(wxChar
* szOut
, const wxChar cIn
, size_t len
)
912 wxChar
* szRet
= szOut
;
920 #else /* !wxUSE_UNICODE */
921 # define wxTmemchr memchr
922 # define wxTmemcmp memcmp
923 # define wxTmemcpy memcpy
924 # define wxTmemmove memmove
925 # define wxTmemset memset
926 #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
928 #endif /*__cplusplus*/
930 #endif /* _WX_WXCRT_H_ */