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 */
15 #ifndef _WX_WXCRTBASE_H_
16 #define _WX_WXCRTBASE_H_
18 /* -------------------------------------------------------------------------
19 headers and missing declarations
20 ------------------------------------------------------------------------- */
22 #include "wx/chartype.h"
25 Standard headers we need here.
27 NB: don't include any wxWidgets headers here because almost all of them
38 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
39 char *strtok_r(char *, const char *, char **);
43 a few compilers don't have the (non standard but common) isascii function,
44 define it ourselves for them
47 #if defined(__MWERKS__)
48 #define wxNEED_ISASCII
49 #elif defined(_WIN32_WCE)
51 #define wxNEED_ISASCII
57 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
62 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
64 #endif /* _WIN32_WCE */
66 /* string.h functions */
68 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
70 #elif defined(__WXWINCE__)
78 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
81 /* missing functions in some WinCE versions */
83 #if (_WIN32_WCE < 300)
84 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
86 #endif /* _WIN32_WCE */
89 #if defined(__MWERKS__)
90 /* Metrowerks only has wide char support for OS X >= 10.3 */
91 #if !defined(__DARWIN__) || \
92 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
93 #define wxHAVE_MWERKS_UNICODE
96 #ifdef wxHAVE_MWERKS_UNICODE
97 #define HAVE_WPRINTF 1
98 #define HAVE_WCSRTOMBS 1
99 #define HAVE_VSWPRINTF 1
101 #endif /* __MWERKS__ */
104 /* -------------------------------------------------------------------------
105 UTF-8 locale handling
106 ------------------------------------------------------------------------- */
109 #if wxUSE_UNICODE_UTF8
110 // flag indicating whether the current locale uses UTF-8 or not; must be
111 // updated every time the locale is changed!
112 #if wxUSE_UTF8_LOCALE_ONLY
113 #define wxLocaleIsUtf8 true
115 extern WXDLLIMPEXP_BASE
bool wxLocaleIsUtf8
;
117 // function used to update the flag:
118 extern WXDLLIMPEXP_BASE
void wxUpdateLocaleIsUtf8();
119 #else // !wxUSE_UNICODE_UTF8
120 inline void wxUpdateLocaleIsUtf8() {}
121 #endif // wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8
122 #endif // __cplusplus
125 /* -------------------------------------------------------------------------
127 ------------------------------------------------------------------------- */
129 #define wxCRT_StrcatA strcat
130 #define wxCRT_StrchrA strchr
131 #define wxCRT_StrcmpA strcmp
132 #define wxCRT_StrcollA strcoll
133 #define wxCRT_StrcpyA strcpy
134 #define wxCRT_StrcspnA strcspn
135 #define wxCRT_StrlenA strlen
136 #define wxCRT_StrncatA strncat
137 #define wxCRT_StrncmpA strncmp
138 #define wxCRT_StrncpyA strncpy
139 #define wxCRT_StrpbrkA strpbrk
140 #define wxCRT_StrrchrA strrchr
141 #define wxCRT_StrspnA strspn
142 #define wxCRT_StrstrA strstr
143 #define wxCRT_StrxfrmA strxfrm
146 The system C library on Mac OS X 10.2 and below does not support unicode: in
147 other words all wide-character functions such as towupper et al. do simply
148 not exist so we need to provide our own in that context, except for the
149 wchar_t definition/typedef itself.
151 We need to do this for both project builder and CodeWarrior as the latter
152 uses the system C library in Mach builds for wide character support, which
153 as mentioned does not exist on 10.2 and below.
155 #if defined(__DARWIN__) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2)
156 #define wxHAS_NO_WCS_FUNCTIONS
159 #ifndef wxHAS_NO_WCS_FUNCTIONS
160 #define wxCRT_StrcatW wcscat
161 #define wxCRT_StrchrW wcschr
162 #define wxCRT_StrcmpW wcscmp
163 #define wxCRT_StrcollW wcscoll
164 #define wxCRT_StrcpyW wcscpy
165 #define wxCRT_StrcspnW wcscspn
166 #define wxCRT_StrncatW wcsncat
167 #define wxCRT_StrncmpW wcsncmp
168 #define wxCRT_StrncpyW wcsncpy
169 #define wxCRT_StrpbrkW wcspbrk
170 #define wxCRT_StrrchrW wcsrchr
171 #define wxCRT_StrspnW wcsspn
172 #define wxCRT_StrstrW wcsstr
173 #define wxCRT_StrxfrmW wcsxfrm
175 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under
176 Mac and VC++ for Windows CE don't provide it; additionally, gcc under
177 Mac doesn't have wcsdup: */
178 #if defined(__VISUALC__) && __VISUALC__ >= 1400
179 #define wxCRT_StrdupA _strdup
180 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
181 #define wxCRT_StrdupA strdup
183 #if defined(__WINDOWS__)
184 #define wxCRT_StrdupW _wcsdup
185 #elif !defined(__DARWIN__)
186 #define wxCRT_StrdupW wcsdup
189 #define wxCRT_StrdupA strdup
190 /* the rest is implemented in our code */
193 #ifdef wxHAVE_TCHAR_SUPPORT
194 /* we surely have wchar_t if we have TCHAR have wcslen() */
198 #endif /* wxHAVE_TCHAR_SUPPORT */
201 #define wxCRT_StrlenW wcslen
204 #define wxCRT_StrtodA strtod
205 #define wxCRT_StrtolA strtol
206 #define wxCRT_StrtoulA strtoul
207 #define wxCRT_StrtodW wcstod
208 #define wxCRT_StrtolW wcstol
209 #define wxCRT_StrtoulW wcstoul
212 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
213 #define wxCRT_StrtollA _strtoi64
214 #define wxCRT_StrtoullA _strtoui64
215 #define wxCRT_StrtollW _wcstoi64
216 #define wxCRT_StrtoullW _wcstoui64
220 #define wxCRT_StrtollA strtoll
221 #define wxCRT_StrtoullA strtoull
222 #endif /* HAVE_STRTOULL */
224 /* assume that we have wcstoull(), which is also C99, too */
225 #define wxCRT_StrtollW wcstoll
226 #define wxCRT_StrtoullW wcstoull
227 #endif /* HAVE_WCSTOULL */
231 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
233 /* note that we definitely are going to need our own version for widechar
235 #if !defined(wxCRT_StricmpA)
236 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
237 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
238 defined(__EMX__) || defined(__DJGPP__)
239 #define wxCRT_StricmpA stricmp
240 #define wxCRT_StrnicmpA strnicmp
241 #elif defined(__WXPALMOS__)
242 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
243 * quick hack should do until one can be written.
245 #define wxCRT_StricmpA StrCaselessCompare
246 #define wxCRT_StrnicmpA strnicmp
247 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
248 (defined(__MWERKS__) && defined(__INTEL__))
249 #define wxCRT_StricmpA _stricmp
250 #define wxCRT_StrnicmpA _strnicmp
251 #elif defined(__UNIX__) || defined(__GNUWIN32__)
252 #define wxCRT_StricmpA strcasecmp
253 #define wxCRT_StrnicmpA strncasecmp
254 /* #else -- use wxWidgets implementation */
256 #endif /* !defined(wxCRT_StricmpA) */
257 /* FIXME-UTF8: use wcs(n)casecmp if available for *W versions */
260 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
262 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
264 /* these are extern "C" because they are used by regex lib: */
269 #ifndef wxCRT_StrlenW
270 WXDLLIMPEXP_BASE
size_t wxCRT_StrlenW(const wchar_t *s
);
273 #ifndef wxCRT_StrncmpW
274 WXDLLIMPEXP_BASE
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
);
281 /* FIXME-UTF8: remove this once we are Unicode only */
283 #define wxCRT_StrlenNative wxCRT_StrlenW
284 #define wxCRT_StrncmpNative wxCRT_StrncmpW
285 #define wxCRT_ToupperNative wxCRT_ToupperW
286 #define wxCRT_TolowerNative wxCRT_TolowerW
288 #define wxCRT_StrlenNative wxCRT_StrlenA
289 #define wxCRT_StrncmpNative wxCRT_StrncmpA
290 #define wxCRT_ToupperNative toupper
291 #define wxCRT_TolowerNative tolower
294 #ifndef wxCRT_StrcatW
295 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
);
298 #ifndef wxCRT_StrchrW
299 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
);
302 #ifndef wxCRT_StrcmpW
303 WXDLLIMPEXP_BASE
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
);
306 #ifndef wxCRT_StrcollW
307 WXDLLIMPEXP_BASE
int wxCRT_StrcollW(const wchar_t *s1
, const wchar_t *s2
);
310 #ifndef wxCRT_StrcpyW
311 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
);
314 #ifndef wxCRT_StrcspnW
315 WXDLLIMPEXP_BASE
size_t wxCRT_StrcspnW(const wchar_t *s
, const wchar_t *reject
);
318 #ifndef wxCRT_StrncatW
319 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
);
322 #ifndef wxCRT_StrncpyW
323 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
);
326 #ifndef wxCRT_StrpbrkW
327 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
);
330 #ifndef wxCRT_StrrchrW
331 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
);
334 #ifndef wxCRT_StrspnW
335 WXDLLIMPEXP_BASE
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
);
338 #ifndef wxCRT_StrstrW
339 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
);
342 #ifndef wxCRT_StrtodW
343 WXDLLIMPEXP_BASE
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
);
346 #ifndef wxCRT_StrtolW
347 WXDLLIMPEXP_BASE
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
350 #ifndef wxCRT_StrtoulW
351 WXDLLIMPEXP_BASE
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
354 #ifndef wxCRT_StrxfrmW
355 WXDLLIMPEXP_BASE
size_t wxCRT_StrxfrmW(wchar_t *dest
, const wchar_t *src
, size_t n
);
358 #ifndef wxCRT_StrdupA
359 WXDLLIMPEXP_BASE
char *wxCRT_StrdupA(const char *psz
);
362 #ifndef wxCRT_StrdupW
363 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrdupW(const wchar_t *pwz
);
366 #ifndef wxCRT_StricmpA
367 WXDLLIMPEXP_BASE
int wxCRT_StricmpA(const char *psz1
, const char *psz2
);
370 #ifndef wxCRT_StricmpW
371 WXDLLIMPEXP_BASE
int wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
);
374 #ifndef wxCRT_StrnicmpA
375 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpA(const char *psz1
, const char *psz2
, size_t len
);
378 #ifndef wxCRT_StrnicmpW
379 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpW(const wchar_t *psz1
, const wchar_t *psz2
, size_t len
);
382 #ifndef wxCRT_StrtokA
383 WXDLLIMPEXP_BASE
char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
);
386 #ifndef wxCRT_StrtokW
387 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
);
390 /* supply strtoll and strtoull, if needed */
391 #ifndef wxCRT_StrtollA
392 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollA(const char* nptr
, char** endptr
, int base
);
393 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullA(const char* nptr
, char** endptr
, int base
);
395 #ifndef wxCRT_StrtollW
396 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
, wchar_t** endptr
, int base
);
397 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
, wchar_t** endptr
, int base
);
401 /* -------------------------------------------------------------------------
403 ------------------------------------------------------------------------- */
405 #if defined(__UNIX__) || defined(__WXMAC__)
412 /* these functions are only needed in the form used for filenames (i.e. char*
413 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
414 #if wxMBFILES || !wxUSE_UNICODE // ANSI filenames
416 #define wxCRT_Fopen fopen
417 #define wxCRT_Freopen freopen
418 #define wxCRT_Remove remove
419 #define wxCRT_Rename rename
421 #else // Unicode filenames
423 /* special case: these functions are missing under Win9x with Unicows so we
424 have to implement them ourselves */
425 #if wxUSE_UNICODE_MSLU
426 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfopen(const wchar_t *name
, const wchar_t *mode
);
427 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfreopen(const wchar_t *name
, const wchar_t *mode
, FILE *stream
);
428 WXDLLIMPEXP_BASE
int wxMSLU__wrename(const wchar_t *oldname
, const wchar_t *newname
);
429 WXDLLIMPEXP_BASE
int wxMSLU__wremove(const wchar_t *name
);
430 #define wxCRT_Fopen wxMSLU__wfopen
431 #define wxCRT_Remove wxMSLU__wremove
432 #define wxCRT_Rename wxMSLU__wrename
434 #define wxCRT_Rename _wrename
435 #define wxCRT_Fopen _wfopen
436 #define wxCRT_Freopen _wfreopen
438 /* carefully: wxCRT_Remove() must return 0 on success while
439 DeleteFile() returns 0 on error, so don't just define one as
441 int wxCRT_Remove(const wchar_t *path
);
443 #define wxCRT_Remove _wremove
447 #endif // wxMBFILES/!wxMBFILES
449 #define wxCRT_PutsA puts
450 #define wxCRT_FputsA fputs
451 #define wxCRT_FgetsA fgets
452 #define wxCRT_FputcA fputc
453 #define wxCRT_FgetcA fgetc
454 #define wxCRT_UngetcA ungetc
456 #ifndef wxHAS_NO_WCS_FUNCTIONS
457 #ifdef wxHAVE_TCHAR_SUPPORT
458 #define wxCRT_PutsW _putws
459 #define wxCRT_FputsW fputws
460 #define wxCRT_FputcW fputwc
463 #define wxCRT_FputsW fputws
466 #define wxCRT_PutsW putws
469 #define wxCRT_FputcW fputwc
471 #define wxCRT_FgetsW fgetws
472 #endif // !wxHAS_NO_WCS_FUNCTIONS
475 WXDLLIMPEXP_BASE
int wxCRT_PutsW(const wchar_t *ws
);
479 WXDLLIMPEXP_BASE
int wxCRT_FputsW(const wchar_t *ch
, FILE *stream
);
483 WXDLLIMPEXP_BASE
int wxCRT_FputcW(wchar_t wc
, FILE *stream
);
486 #define wxCRT_TmpnamA tmpnam
488 #define wxCRT_TmpnamW _wtmpnam
491 #ifndef wxCRT_TmpnamW
492 WXDLLIMPEXP_BASE
wchar_t *wxCRT_TmpnamW(wchar_t *s
);
495 #define wxCRT_PerrorA perror
496 #ifdef wxHAVE_TCHAR_SUPPORT
497 #define wxCRT_PerrorW _wperror
500 /* -------------------------------------------------------------------------
502 ------------------------------------------------------------------------- */
504 /* there are no env vars at all under CE, so no _tgetenv neither */
506 /* can't define as inline function as this is a C file... */
507 #define wxCRT_GetenvA(name) ((char*)NULL)
508 #define wxCRT_GetenvW(name) ((wchar_t*)NULL)
510 #define wxCRT_GetenvA getenv
512 #define wxCRT_GetenvW _wgetenv
516 #ifndef wxCRT_GetenvW
517 WXDLLIMPEXP_BASE
wchar_t * wxCRT_GetenvW(const wchar_t *name
);
521 #define wxCRT_SystemA system
522 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
523 #if defined(_tsystem)
524 #define wxCRT_SystemW _wsystem
527 #define wxCRT_AtofA atof
528 #define wxCRT_AtoiA atoi
529 #define wxCRT_AtolA atol
531 #if defined(__MWERKS__)
533 #define wxCRT_AtofW watof
534 #define wxCRT_AtoiW watoi
535 #define wxCRT_AtolW watol
536 /* else: use ANSI versions */
538 #elif defined(wxHAVE_TCHAR_SUPPORT)
539 #define wxCRT_AtoiW _wtoi
540 #define wxCRT_AtolW _wtol
541 /* _wtof doesn't exist */
543 #define wxCRT_AtofW(s) wcstof(s, NULL)
544 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
545 /* wcstoi doesn't exist */
549 There are 2 unrelated problems with these functions under Mac:
550 a) Metrowerks MSL CRT implements them strictly in C99 sense and
551 doesn't support (very common) extension of allowing to call
552 mbstowcs(NULL, ...) which makes it pretty useless as you can't
553 know the size of the needed buffer
554 b) OS X <= 10.2 declares and even defined these functions but
555 doesn't really implement them -- they always return an error
557 So use our own replacements in both cases.
559 #if defined(__MWERKS__) && defined(__MSL__)
560 #define wxNEED_WX_MBSTOWCS
564 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
565 #define wxNEED_WX_MBSTOWCS
569 #ifdef wxNEED_WX_MBSTOWCS
570 /* even though they are defined and "implemented", they are bad and just
571 stubs so we need our own - we need these even in ANSI builds!! */
572 WXDLLIMPEXP_BASE
size_t wxMbstowcs(wchar_t *, const char *, size_t);
573 WXDLLIMPEXP_BASE
size_t wxWcstombs(char *, const wchar_t *, size_t);
575 #define wxMbstowcs mbstowcs
576 #define wxWcstombs wcstombs
581 /* -------------------------------------------------------------------------
583 ------------------------------------------------------------------------- */
585 #define wxCRT_StrftimeA strftime
586 /* FIXME-UTF8: when is this available? */
587 #define wxCRT_StrftimeW wcsftime
589 #ifndef wxCRT_StrftimeW
590 WXDLLIMPEXP_BASE
size_t wxCRT_StrftimeW(wchar_t *s
, size_t max
,
592 const struct tm
*tm
);
597 /* -------------------------------------------------------------------------
599 ------------------------------------------------------------------------- */
601 #ifdef wxHAS_NO_WCS_FUNCTIONS
602 #define wxNEED_WX_CTYPE_H
606 #define WXWCHAR_T_CAST(c) (wint_t)(c)
608 #define WXWCHAR_T_CAST(c) c
611 #ifdef wxNEED_WX_CTYPE_H
613 /* RN: Used only under OSX <= 10.2 currently */
614 WXDLLIMPEXP_BASE
int wxCRT_IsalnumW(wchar_t ch
);
615 WXDLLIMPEXP_BASE
int wxCRT_IsalphaW(wchar_t ch
);
616 WXDLLIMPEXP_BASE
int wxCRT_IscntrlW(wchar_t ch
);
617 WXDLLIMPEXP_BASE
int wxCRT_IsdigitW(wchar_t ch
);
618 WXDLLIMPEXP_BASE
int wxCRT_IsgraphW(wchar_t ch
);
619 WXDLLIMPEXP_BASE
int wxCRT_IslowerW(wchar_t ch
);
620 WXDLLIMPEXP_BASE
int wxCRT_IsprintW(wchar_t ch
);
621 WXDLLIMPEXP_BASE
int wxCRT_IspunctW(wchar_t ch
);
622 WXDLLIMPEXP_BASE
int wxCRT_IsspaceW(wchar_t ch
);
623 WXDLLIMPEXP_BASE
int wxCRT_IsupperW(wchar_t ch
);
624 WXDLLIMPEXP_BASE
int wxCRT_IsxdigitW(wchar_t ch
);
625 /* extern "C" because needed by regex code */
626 WXDLLIMPEXP_BASE
extern "C" int wxCRT_TolowerW(wchar_t ch
);
627 WXDLLIMPEXP_BASE
extern "C" int wxCRT_ToupperW(wchar_t ch
);
629 #else // !defined(wxNEED_WX_CTYPE_H)
631 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
632 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
633 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
634 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
635 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
636 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
637 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
638 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
639 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
640 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
641 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
644 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
645 /* /usr/include/wctype.h incorrectly declares translations */
646 /* tables which provokes tons of compile-time warnings -- try */
647 /* to correct this */
648 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
649 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
650 #else /* !glibc 2.0 */
651 #define wxCRT_TolowerW towlower
652 #define wxCRT_ToupperW towupper
655 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
656 with signed chars < 0, so "fix" it here. */
657 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
658 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
659 #endif // __GLIBC__/!__GLIBC__
660 #endif // !defined(wxNEED_WX_CTYPE_H)
666 /* -------------------------------------------------------------------------
667 wx wrappers for CRT functions in both char* and wchar_t* versions
668 ------------------------------------------------------------------------- */
672 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
673 * for buffer.h and stringimpl.h (both of which must be included before
674 * string.h, which is required by wxcrt.h) to have them here: */
676 /* safe version of strlen() (returns 0 if passed NULL pointer) */
677 inline size_t wxStrlen(const char *s
) { return s
? wxCRT_StrlenA(s
) : 0; }
678 inline size_t wxStrlen(const wchar_t *s
) { return s
? wxCRT_StrlenW(s
) : 0; }
679 #define wxWcslen wxCRT_StrlenW
681 #define wxStrdupA wxCRT_StrdupA
682 #define wxStrdupW wxCRT_StrdupW
683 inline char* wxStrdup(const char *s
) { return wxCRT_StrdupA(s
); }
684 inline wchar_t* wxStrdup(const wchar_t *s
) { return wxCRT_StrdupW(s
); }
686 #endif /* __cplusplus */
688 #endif /* _WX_WXCRTBASE_H_ */