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 */
23 #if wxUSE_UNICODE_UTF8
24 // flag indicating whether the current locale uses UTF-8 or not; must be
25 // updated every time the locale is changed!
26 #if !wxUSE_UTF8_LOCALE_ONLY
27 extern WXDLLIMPEXP_BASE
bool wxLocaleIsUtf8
;
29 // function used to update the flag:
30 extern WXDLLIMPEXP_BASE
void wxUpdateLocaleIsUtf8();
31 #else // !wxUSE_UNICODE_UTF8
32 inline void wxUpdateLocaleIsUtf8() {}
33 #endif // wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8
36 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
37 char *strtok_r(char *, const char *, char **);
42 Standard headers we need here.
44 NB: don't include any wxWidgets headers here because almost all of them include
48 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
49 /* and VC++ for Windows CE don't provide it */
50 #if defined(__VISUALC__) && __VISUALC__ >= 1400
51 #define wxStrdupA _strdup
52 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
53 /* use #define, not inline wrapper, as it is tested with #ifndef below */
54 #define wxStrdupA strdup
57 #if defined(__MWERKS__)
58 /* Metrowerks only has wide char support for OS X >= 10.3 */
59 #if !defined(__DARWIN__) || \
60 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
61 #define wxHAVE_MWERKS_UNICODE
64 #ifdef wxHAVE_MWERKS_UNICODE
65 #define HAVE_WPRINTF 1
66 #define HAVE_WCSRTOMBS 1
67 #define HAVE_VSWPRINTF 1
69 #endif /* __MWERKS__ */
71 #ifdef wxHAVE_TCHAR_SUPPORT
72 /* we surely have wchar_t if we have TCHAR have wcslen() */
76 #endif /* wxHAVE_TCHAR_SUPPORT */
79 define wxFoo() function for each standard foo() function whose signature
80 (exceptionally including the return type) includes any mention of char:
81 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
82 the same signature but with char replaced by wxChar which allows us to
83 use it in Unicode build as well
86 #ifdef wxHAVE_TCHAR_SUPPORT
89 #if defined(__WATCOMC__) && defined(UNICODE)
90 #define WXWCHAR_T_CAST(c) (wint_t)(c)
92 #define WXWCHAR_T_CAST(c) c
95 /* ctype.h functions */
96 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
97 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
98 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
99 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
100 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
101 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
102 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
103 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
104 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
105 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
106 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
109 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
110 signed chars < 0, so "fix" it here.
112 #define wxTolower(c) _totlower((wxUChar)(wxChar)(c))
113 #define wxToupper(c) _totupper((wxUChar)(wxChar)(c))
115 /* locale.h functons */
116 #define wxSetlocale_ _tsetlocale
118 /* string.h functions */
119 #define wxStrcat _tcscat
120 #define wxStrchr _tcschr
121 #define wxStrcmp _tcscmp
122 #define wxStrcoll _tcscoll
123 #define wxStrcpy _tcscpy
124 #define wxStrcspn _tcscspn
125 #define wxStrdupW _wcsdup /* notice the 'W'! */
126 #define wxStrftime _tcsftime
127 #define wxStricmp _tcsicmp
128 #define wxStrnicmp _tcsnicmp
129 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
130 #define wxStrncat _tcsncat
131 #define wxStrncmp _tcsncmp
132 #define wxStrncpy _tcsncpy
133 #define wxStrpbrk _tcspbrk
134 #define wxStrrchr _tcsrchr
135 #define wxStrspn _tcsspn
136 #define wxStrstr _tcsstr
137 #define wxStrtod _tcstod
138 #define wxStrtol _tcstol
139 #define wxStrtoul _tcstoul
141 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
142 #define wxStrtoll _tcstoi64
143 #define wxStrtoull _tcstoui64
146 #define wxStrxfrm _tcsxfrm
148 /* stdio.h functions */
149 #define wxFgetc _fgettc
150 #define wxFgetchar _fgettchar
151 #define wxFgets _fgetts
152 #if wxUSE_UNICODE_MSLU
153 WXDLLIMPEXP_BASE
FILE * wxMSLU__tfopen(const wxChar
*name
, const wxChar
*mode
);
155 #define wxFopen wxMSLU__tfopen
157 #define wxFopen _tfopen
159 #define wxFputc _fputtc
160 #define wxFputchar _fputtchar
161 #define wxFputs _fputts
162 #define wxFreopen _tfreopen
163 #define wxGetc _gettc
164 #define wxGetchar _gettchar
165 #define wxGets _getts
166 #define wxPerror _tperror
167 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
168 #define wxPutchar _puttchar
169 #define wxPuts _putts
171 #define wxTmpnam _ttmpnam
172 #define wxUngetc _tungetc
174 /* special case: these functions are missing under Win9x with Unicows so we */
175 /* have to implement them ourselves */
176 #if wxUSE_UNICODE_MSLU
177 WXDLLIMPEXP_BASE
int wxMSLU__trename(const wxChar
*oldname
, const wxChar
*newname
);
178 WXDLLIMPEXP_BASE
int wxMSLU__tremove(const wxChar
*name
);
180 #define wxRemove wxMSLU__tremove
181 #define wxRename wxMSLU__trename
184 /* carefully: wxRemove() must return 0 on success while DeleteFile()
185 returns 0 on error, so don't just define one as the other */
186 int wxRemove(const wxChar
*path
);
188 #define wxRemove _tremove
189 #define wxRename _trename
193 /* stdlib.h functions */
196 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
197 /* there are no env vars at all under CE, so no _tgetenv neither */
199 /* can't define as inline function as this is a C file... */
200 #define wxGetenv(name) ((wxChar *)NULL)
202 #define wxGetenv _tgetenv
204 #define wxSystem _tsystem
206 /* time.h functions */
207 #define wxAsctime _tasctime
208 #define wxCtime _tctime
210 #define wxMbstowcs mbstowcs
211 #define wxWcstombs wcstombs
212 #else /* !TCHAR-aware compilers */
214 There are 2 unrelated problems with these functions under Mac:
215 a) Metrowerks MSL CRT implements them strictly in C99 sense and
216 doesn't support (very common) extension of allowing to call
217 mbstowcs(NULL, ...) which makes it pretty useless as you can't
218 know the size of the needed buffer
219 b) OS X <= 10.2 declares and even defined these functions but
220 doesn't really implement them -- they always return an error
222 So use our own replacements in both cases.
224 #if defined(__MWERKS__) && defined(__MSL__)
225 #define wxNEED_WX_MBSTOWCS
229 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
230 #define wxNEED_WX_MBSTOWCS
234 #ifdef wxNEED_WX_MBSTOWCS
235 /* even though they are defined and "implemented", they are bad and just
236 stubs so we need our own - we need these even in ANSI builds!! */
237 WXDLLIMPEXP_BASE
size_t wxMbstowcs (wchar_t *, const char *, size_t);
238 WXDLLIMPEXP_BASE
size_t wxWcstombs (char *, const wchar_t *, size_t);
240 #define wxMbstowcs mbstowcs
241 #define wxWcstombs wcstombs
245 The system C library on Mac OS X 10.2 and below does not support
246 unicode: in other words all wide-character functions such as towupper et
247 al. do simply not exist so we need to provide our own in that context,
248 except for the wchar_t definition/typedef itself.
250 We need to do this for both project builder and CodeWarrior as
251 the latter uses the system C library in Mach builds for wide character
252 support, which as mentioned does not exist on 10.2 and below.
254 #if wxUSE_UNICODE && \
255 defined(__DARWIN__) && \
256 ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
257 /* we need everything! */
258 #define wxNEED_WX_STRING_H
259 #define wxNEED_WX_CTYPE_H
261 #define wxFgetchar(c) wxFgetc(c, stdin)
262 #define wxFputc wxPutc
263 #define wxFputchar(c) wxPutc(c, stdout)
264 #define wxGetc wxFgetc
265 #define wxGetchar(c) wxFgetc(c, stdin)
272 #define wxNEED_UNGETC
278 int wxFputs(const wxChar
*ch
, FILE *stream
);
279 int wxPuts(const wxChar
*ws
);
280 int wxPutc(wxChar ch
, FILE *stream
);
285 WXDLLIMPEXP_BASE
size_t wxStrlen_(const wxChar
*s
);
290 #define wxPutchar(wch) wxPutc(wch, stdout)
292 #define wxNEED_PRINTF_CONVERSION
293 #define wxNEED_WX_STDIO_H
294 #define wxNEED_WX_STDLIB_H
295 #define wxNEED_WX_TIME_H
300 /* this is probably glibc-specific */
301 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
302 /* ctype.h functions (wctype.h) */
303 #define wxIsalnum iswalnum
304 #define wxIsalpha iswalpha
305 #define wxIscntrl iswcntrl
306 #define wxIsdigit iswdigit
307 #define wxIsgraph iswgraph
308 #define wxIslower iswlower
309 #define wxIsprint iswprint
310 #define wxIspunct iswpunct
311 #define wxIsspace iswspace
312 #define wxIsupper iswupper
313 #define wxIsxdigit iswxdigit
315 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
316 /* /usr/include/wctype.h incorrectly declares translations */
317 /* tables which provokes tons of compile-time warnings -- try */
318 /* to correct this */
319 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
320 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
321 #else /* !glibc 2.0 */
322 #define wxTolower towlower
323 #define wxToupper towupper
324 #endif /* gcc/!gcc */
326 /* string.h functions (wchar.h) */
327 #define wxStrcat wcscat
328 #define wxStrchr wcschr
329 #define wxStrcmp wcscmp
330 #define wxStrcoll wcscoll
331 #define wxStrcpy wcscpy
332 #define wxStrcspn wcscspn
333 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
334 #define wxStrncat wcsncat
335 #define wxStrncmp wcsncmp
336 #define wxStrncpy wcsncpy
337 #define wxStrpbrk wcspbrk
338 #define wxStrrchr wcsrchr
339 #define wxStrspn wcsspn
340 #define wxStrstr wcsstr
341 #define wxStrtod wcstod
342 #define wxStrtol wcstol
343 #define wxStrtoul wcstoul
345 /* assume that we have wcstoull(), which is also C99, too */
346 #define wxStrtoll wcstoll
347 #define wxStrtoull wcstoull
348 #endif /* HAVE_WCSTOULL */
349 #define wxStrxfrm wcsxfrm
351 #define wxFgetc fgetwc
352 #define wxFgetchar fgetwchar
353 #define wxFgets fgetws
354 #define wxFputc fputwc
355 #define wxFputchar fputwchar
357 #define wxGetchar getwchar
359 #define wxUngetc ungetwc
362 #define wxFputs fputws
366 int wxFputs(const wxChar
*ch
, FILE *stream
);
374 int wxPutc(wxChar ch
, FILE *stream
);
378 #define wxPutchar wputchar
380 #define wxPutchar(wch) wxPutc(wch, stdout)
387 int wxPuts(const wxChar
*ws
);
390 /* we need %s to %ls conversion for printf and scanf etc */
391 #define wxNEED_PRINTF_CONVERSION
393 /* glibc doesn't have wide char equivalents of the other stuff so */
394 /* use our own versions */
395 #define wxNEED_WX_STDIO_H
396 #define wxNEED_WX_STDLIB_H
397 #define wxNEED_WX_TIME_H
398 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
399 /* ctype.h functions (wctype.h) */
400 #define wxIsalnum iswalnum
401 #define wxIsalpha iswalpha
402 #define wxIscntrl iswcntrl
403 #define wxIsdigit iswdigit
404 #define wxIsgraph iswgraph
405 #define wxIslower iswlower
406 #define wxIsprint iswprint
407 #define wxIspunct iswpunct
408 #define wxIsspace iswspace
409 #define wxIsupper iswupper
410 #define wxIsxdigit iswxdigit
411 #define wxTolower towlower
412 #define wxToupper towupper
414 /* string.h functions (wchar.h) */
415 #define wxStrcat wcscat
416 #define wxStrchr wcschr
417 #define wxStrcmp wcscmp
418 #define wxStrcoll wcscoll
419 #define wxStrcpy wcscpy
420 #define wxStrcspn wcscspn
421 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
422 #define wxStrncat wcsncat
423 #define wxStrncmp wcsncmp
424 #define wxStrncpy wcsncpy
425 #define wxStrpbrk wcspbrk
426 #define wxStrrchr wcsrchr
427 #define wxStrspn wcsspn
428 #define wxStrstr wcsstr
429 #define wxStrtod wcstod
430 #define wxStrtol wcstol
431 #define wxStrtoul wcstoul
432 #define wxStrxfrm wcsxfrm
434 #define wxFgetc fgetwc
435 #define wxFgetchar fgetwchar
436 #define wxFgets fgetws
437 #define wxFputc fputwc
438 #define wxFputchar fputwchar
440 #define wxGetchar getwchar
442 #define wxUngetc ungetwc
444 #define wxNEED_PRINTF_CONVERSION
447 #define wxPutchar putwchar
448 #define wxFputs fputws
450 /* stdio.h functions */
452 #define wxNEED_WX_STDIO_H
454 /* stdlib.h functions */
456 #define wxNEED_WX_STDLIB_H
461 #define wxGetenv(a) ((wxChar*)NULL)
462 #define wxSystem(a) ((int)NULL)
464 /* time.h functions */
465 #define wxAsctime wasciitime
466 #define wxCtime wctime
467 /* #define wxStrftime wcsftime */
469 #define wxNEED_WX_TIME_H
470 #else /* !metrowerks for apple */
471 #error "Please define wide character functions for your environment"
477 /* ctype.h functions */
478 #define wxIsalnum isalnum
479 #define wxIsalpha isalpha
480 #define wxIscntrl iscntrl
481 #define wxIsdigit isdigit
482 #define wxIsgraph isgraph
483 #define wxIslower islower
484 #define wxIsprint isprint
485 #define wxIspunct ispunct
486 #define wxIsspace isspace
487 #define wxIsupper isupper
488 #define wxIsxdigit isxdigit
489 #define wxTolower tolower
490 #define wxToupper toupper
492 /* locale.h functons */
493 #define wxSetlocale_ setlocale
495 /* string.h functions */
496 #define wxStrcat strcat
497 #define wxStrchr strchr
498 #define wxStrcmp strcmp
499 #define wxStrcoll strcoll
500 #define wxStrcpy strcpy
501 #define wxStrcspn strcspn
503 /* wxStricmp and wxStrnicmp are defined below */
504 #define wxStrlen_ strlen /* used in wxStrlen inline function */
505 #define wxStrncat strncat
506 #define wxStrncmp strncmp
507 #define wxStrncpy strncpy
508 #define wxStrpbrk strpbrk
509 #define wxStrrchr strrchr
510 #define wxStrspn strspn
511 #define wxStrstr strstr
512 #define wxStrtod strtod
514 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
516 #define wxStrtol strtol
517 #define wxStrtoul strtoul
519 /* assume that we have wcstoull(), which is also C99, too */
520 #define wxStrtoll strtoll
521 #define wxStrtoull strtoull
522 #endif /* HAVE_WCSTOULL */
523 #define wxStrxfrm strxfrm
525 /* stdio.h functions */
526 #define wxFopen fopen
527 #define wxFreopen freopen
528 #define wxRemove remove
529 #define wxRename rename
531 #define wxPerror perror
532 #define wxTmpnam tmpnam
534 #define wxFgetc fgetc
535 #define wxFgetchar fgetchar
536 #define wxFgets fgets
537 #define wxFputc fputc
538 #define wxFputs fputs
539 #define wxFputchar fputchar
541 #define wxGetchar getchar
544 #define wxPutchar putchar
546 #define wxUngetc ungetc
548 /* stdlib.h functions */
552 #define wxGetenv getenv
553 #define wxSystem system
555 /* time.h functions */
556 #define wxAsctime asctime
557 #define wxCtime ctime
558 #define wxStrftime strftime
559 #endif /* Unicode/ASCII */
560 #endif /* TCHAR-aware compilers/the others */
563 various special cases
566 /* define wxStricmp and wxStrnicmp for various compilers */
568 /* note that in Unicode mode we definitely are going to need our own version */
569 #if !defined(wxStricmp) && !wxUSE_UNICODE
570 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
571 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
572 defined(__EMX__) || defined(__DJGPP__)
573 #define wxStricmp stricmp
574 #define wxStrnicmp strnicmp
575 #elif defined(__WXPALMOS__)
576 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
577 * quick hack should do until one can be written.
579 #define wxStricmp StrCaselessCompare
580 #define wxStrnicmp strnicmp
581 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
582 (defined(__MWERKS__) && defined(__INTEL__))
583 #define wxStricmp _stricmp
584 #define wxStrnicmp _strnicmp
585 #elif defined(__UNIX__) || defined(__GNUWIN32__)
586 #define wxStricmp strcasecmp
587 #define wxStrnicmp strncasecmp
588 /* #else -- use wxWidgets implementation */
590 #endif /* !defined(wxStricmp) */
592 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
593 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
594 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
597 #define wxWcslen wcslen
599 WXDLLIMPEXP_BASE
size_t wxWcslen(const wchar_t *s
);
601 #endif /* wxUSE_WCHAR_T */
604 /* checks whether the passed in pointer is NULL and if the string is empty */
605 inline bool wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
607 /* safe version of strlen() (returns 0 if passed NULL pointer) */
608 inline size_t wxStrlen(const wxChar
*psz
) { return psz
? wxStrlen_(psz
) : 0; }
612 each of strdup() and wcsdup() may or may not be available but we need both
613 of them anyhow for wx/buffer.h so we define the missing one(s) in
614 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
615 defined -- if this is somehow not the case in some situations, please
616 correct that and not the lines here
619 #define wxStrdup wxStrdupW
621 #define wxStrdup wxStrdupA
625 WXDLLIMPEXP_BASE
bool wxOKlibc(); /* for internal use */
629 /* supply strtoll and strtoull, if needed */
630 WXDLLIMPEXP_BASE wxLongLong_t
wxStrtoll(const wxChar
* nptr
, wxChar
** endptr
, int base
);
631 WXDLLIMPEXP_BASE wxULongLong_t
wxStrtoull(const wxChar
* nptr
, wxChar
** endptr
, int base
);
634 #define wxHAS_STRTOLL
637 In Unicode mode we need to have all standard functions such as wprintf() and
638 so on but not all systems have them so use our own implementations in this
641 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
642 #define wxNEED_WPRINTF
646 various functions which might not be available in libc and for which we
647 provide our own replacements in wxchar.cpp
650 /* ctype.h functions */
652 /* RN: Used only under OSX <= 10.2 currently */
653 #ifdef wxNEED_WX_CTYPE_H
654 WXDLLIMPEXP_BASE
int wxIsalnum(wxChar ch
);
655 WXDLLIMPEXP_BASE
int wxIsalpha(wxChar ch
);
656 WXDLLIMPEXP_BASE
int wxIscntrl(wxChar ch
);
657 WXDLLIMPEXP_BASE
int wxIsdigit(wxChar ch
);
658 WXDLLIMPEXP_BASE
int wxIsgraph(wxChar ch
);
659 WXDLLIMPEXP_BASE
int wxIslower(wxChar ch
);
660 WXDLLIMPEXP_BASE
int wxIsprint(wxChar ch
);
661 WXDLLIMPEXP_BASE
int wxIspunct(wxChar ch
);
662 WXDLLIMPEXP_BASE
int wxIsspace(wxChar ch
);
663 WXDLLIMPEXP_BASE
int wxIsupper(wxChar ch
);
664 WXDLLIMPEXP_BASE
int wxIsxdigit(wxChar ch
);
665 WXDLLIMPEXP_BASE
int wxTolower(wxChar ch
);
666 WXDLLIMPEXP_BASE
int wxToupper(wxChar ch
);
667 #endif /* wxNEED_WX_CTYPE_H */
669 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
670 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
671 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
673 #define wxIsspace(c) ((((unsigned)(wxChar)c) < 128) && isspace(c))
677 a few compilers don't have the (non standard but common) isascii function,
678 define it ourselves for them
681 #if defined(__MWERKS__)
682 #define wxNEED_ISASCII
683 #elif defined(_WIN32_WCE)
684 #if _WIN32_WCE <= 211
685 #define wxNEED_ISASCII
690 #ifdef wxNEED_ISASCII
691 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
695 #if _WIN32_WCE <= 211
696 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
698 #endif /* _WIN32_WCE */
701 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
702 initial versions of this header -- now it is too late to remove it so
703 although we fixed the function/macro name above, still provide the
704 backwards-compatible synonym.
706 #define wxIsctrl wxIscntrl
708 /* string.h functions */
710 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
711 #define wxNEED_STRDUP
712 #elif defined(__WXWINCE__)
713 #if _WIN32_WCE <= 211
714 #define wxNEED_STRDUP
720 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
723 /* RN: Used only under OSX <= 10.2 currently
724 The __cplusplus ifdefs are messy, but they are required to build
725 the regex library, since c does not support function overloading
727 #ifdef wxNEED_WX_STRING_H
731 WXDLLIMPEXP_BASE wxChar
* wxStrcat(wxChar
*dest
, const wxChar
*src
);
732 WXDLLIMPEXP_BASE
const wxChar
* wxStrchr(const wxChar
*s
, wxChar c
);
733 WXDLLIMPEXP_BASE
int wxStrcmp(const wxChar
*s1
, const wxChar
*s2
);
734 WXDLLIMPEXP_BASE
int wxStrcoll(const wxChar
*s1
, const wxChar
*s2
);
735 WXDLLIMPEXP_BASE wxChar
* wxStrcpy(wxChar
*dest
, const wxChar
*src
);
736 WXDLLIMPEXP_BASE
size_t wxStrcspn(const wxChar
*s
, const wxChar
*reject
);
737 WXDLLIMPEXP_BASE wxChar
* wxStrncat(wxChar
*dest
, const wxChar
*src
, size_t n
);
738 WXDLLIMPEXP_BASE
int wxStrncmp(const wxChar
*s1
, const wxChar
*s2
, size_t n
);
739 WXDLLIMPEXP_BASE wxChar
* wxStrncpy(wxChar
*dest
, const wxChar
*src
, size_t n
);
740 WXDLLIMPEXP_BASE
const wxChar
* wxStrpbrk(const wxChar
*s
, const wxChar
*accept
);
741 WXDLLIMPEXP_BASE
const wxChar
* wxStrrchr(const wxChar
*s
, wxChar c
);
742 WXDLLIMPEXP_BASE
size_t wxStrspn(const wxChar
*s
, const wxChar
*accept
);
743 WXDLLIMPEXP_BASE
const wxChar
* wxStrstr(const wxChar
*haystack
, const wxChar
*needle
);
748 /* These functions use C++, so we can't c extern them */
749 WXDLLIMPEXP_BASE
double wxStrtod(const wxChar
*nptr
, wxChar
**endptr
);
750 WXDLLIMPEXP_BASE
long int wxStrtol(const wxChar
*nptr
, wxChar
**endptr
, int base
);
751 WXDLLIMPEXP_BASE
unsigned long int wxStrtoul(const wxChar
*nptr
, wxChar
**endptr
, int base
);
752 WXDLLIMPEXP_BASE
size_t wxStrxfrm(wxChar
*dest
, const wxChar
*src
, size_t n
);
754 /* inlined versions */
756 inline wxChar
* wxStrchr(wxChar
*s
, wxChar c
)
757 { return (wxChar
*)wxStrchr((const wxChar
*)s
, c
); }
758 inline wxChar
* wxStrpbrk(wxChar
*s
, const wxChar
*accept
)
759 { return (wxChar
*)wxStrpbrk((const wxChar
*)s
, accept
); }
760 inline wxChar
* wxStrrchr(wxChar
*s
, wxChar c
)
761 { return (wxChar
*)wxStrrchr((const wxChar
*)s
, c
); }
762 inline wxChar
*wxStrstr(wxChar
*haystack
, const wxChar
*needle
)
763 { return (wxChar
*)wxStrstr((const wxChar
*)haystack
, needle
); }
766 #endif /* wxNEED_WX_STRING_H */
769 WXDLLIMPEXP_BASE
char *wxStrdupA(const char *psz
);
773 WXDLLIMPEXP_BASE
wchar_t *wxStrdupW(const wchar_t *pwz
);
777 WXDLLIMPEXP_BASE
int wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
);
781 WXDLLIMPEXP_BASE
int wxStrnicmp(const wxChar
*psz1
, const wxChar
*psz2
, size_t len
);
785 WXDLLIMPEXP_BASE wxChar
* wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
790 class WXDLLIMPEXP_BASE wxWCharBuffer
;
791 WXDLLIMPEXP_BASE wxWCharBuffer
wxSetlocale_(int category
, const wxChar
*locale
);
792 WXDLLIMPEXP_BASE wxWCharBuffer
wxSetlocale(int category
, const wxChar
*locale
);
794 WXDLLIMPEXP_BASE wxChar
*wxSetlocale(int category
, const wxChar
*locale
);
795 #endif // defined(wxSetlocale_)
796 #endif // __cplusplus
798 /* stdio.h functions */
799 #ifdef wxNEED_WX_STDIO_H
801 WXDLLIMPEXP_BASE
FILE * wxFopen(const wxChar
*path
, const wxChar
*mode
);
802 WXDLLIMPEXP_BASE
FILE * wxFreopen(const wxChar
*path
, const wxChar
*mode
, FILE *stream
);
803 WXDLLIMPEXP_BASE
int wxRemove(const wxChar
*path
);
804 WXDLLIMPEXP_BASE
int wxRename(const wxChar
*oldpath
, const wxChar
*newpath
);
806 /* *printf() family is handled separately */
807 #endif /* wxNEED_WX_STDIO_H */
810 /* stdlib.h functions */
812 WXDLLIMPEXP_BASE
double wxAtof(const wxChar
*psz
);
815 #ifdef wxNEED_WX_STDLIB_H
816 WXDLLIMPEXP_BASE
int wxAtoi(const wxChar
*psz
);
817 WXDLLIMPEXP_BASE
long wxAtol(const wxChar
*psz
);
818 WXDLLIMPEXP_BASE wxChar
* wxGetenv(const wxChar
*name
);
819 WXDLLIMPEXP_BASE
int wxSystem(const wxChar
*psz
);
823 /* time.h functions */
824 #ifdef wxNEED_WX_TIME_H
825 #if defined(__MWERKS__) && defined(macintosh)
828 /*silent gabby compilers*/
830 WXDLLIMPEXP_BASE
size_t wxStrftime(wxChar
*s
, size_t max
,
832 const struct tm
*tm
);
833 #endif /* wxNEED_WX_TIME_H */
837 WXDLLIMPEXP_BASE wxChar
*wxCtime(const time_t *timep
);
841 /* missing functions in some WinCE versions */
843 #if (_WIN32_WCE < 300)
844 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
846 #endif /* _WIN32_WCE */
848 /* multibyte to wide char conversion functions and macros */
851 /* multibyte<->widechar conversion */
852 WXDLLIMPEXP_BASE
size_t wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
853 WXDLLIMPEXP_BASE
size_t wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
856 #define wxMB2WX wxMB2WC
857 #define wxWX2MB wxWC2MB
858 #define wxWC2WX wxStrncpy
859 #define wxWX2WC wxStrncpy
861 #define wxMB2WX wxStrncpy
862 #define wxWX2MB wxStrncpy
863 #define wxWC2WX wxWC2MB
864 #define wxWX2WC wxMB2WC
866 #else /* !wxUSE_UNICODE */
869 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
870 #define wxMB2WC wxStrncpy
871 #define wxWC2MB wxStrncpy
872 #define wxMB2WX wxStrncpy
873 #define wxWX2MB wxStrncpy
874 #define wxWC2WX wxWC2MB
875 #define wxWX2WC wxMB2WC
879 RN: The following are not normal versions of memcpy et al., rather
880 these are either char or widechar versions depending on
881 if unicode is used or not.
887 // RN: We could do the usual tricky compiler detection here,
888 // and use their variant (such as wmemchr, etc.). The problem
889 // is that these functions are quite rare, even though they are
890 // part of the current POSIX standard. In addition, most compilers
891 // (including even MSC) inline them just like we do right in their
895 #include <string.h> //for mem funcs
897 //implement our own wmem variants
898 inline wxChar
* wxTmemchr(const wxChar
* s
, wxChar c
, size_t l
)
900 for(;l
&& *s
!= c
;--l
, ++s
) {}
907 inline int wxTmemcmp(const wxChar
* sz1
, const wxChar
* sz2
, size_t len
)
909 for(; *sz1
== *sz2
&& len
; --len
, ++sz1
, ++sz2
) {}
912 return *sz1
< *sz2
? -1 : *sz1
> *sz2
;
917 inline wxChar
* wxTmemcpy(wxChar
* szOut
, const wxChar
* szIn
, size_t len
)
919 return (wxChar
*) memcpy(szOut
, szIn
, len
* sizeof(wxChar
));
922 inline wxChar
* wxTmemmove(wxChar
* szOut
, const wxChar
* szIn
, size_t len
)
924 return (wxChar
*) memmove(szOut
, szIn
, len
* sizeof(wxChar
));
927 inline wxChar
* wxTmemset(wxChar
* szOut
, const wxChar cIn
, size_t len
)
929 wxChar
* szRet
= szOut
;
937 #else /* !wxUSE_UNICODE */
938 # define wxTmemchr memchr
939 # define wxTmemcmp memcmp
940 # define wxTmemcpy memcpy
941 # define wxTmemmove memmove
942 # define wxTmemset memset
943 #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
945 #endif /*__cplusplus*/
947 #endif /* _WX_WXCRT_H_ */