3 * Purpose: Type-safe ANSI and Unicode builds compatible wrappers for
5 * Author: Joel Farley, Ove Kaaven
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
30 NB2: User code should include wx/crt.h instead of including this
35 #if !defined(__WXPALMOS5__)
39 #if defined(__WXPALMOS__)
47 #if defined(__WINDOWS__) && !defined(__WXWINCE__)
51 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
52 char *strtok_r(char *, const char *, char **);
56 a few compilers don't have the (non standard but common) isascii function,
57 define it ourselves for them
60 #if defined(__MWERKS__)
61 #define wxNEED_ISASCII
62 #elif defined(_WIN32_WCE)
64 #define wxNEED_ISASCII
70 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
75 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
77 #endif /* _WIN32_WCE */
79 /* string.h functions */
81 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
83 #elif defined(__WXWINCE__)
91 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
94 /* missing functions in some WinCE versions */
96 #if (_WIN32_WCE < 300)
97 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
99 #endif /* _WIN32_WCE */
102 #if defined(__MWERKS__)
103 /* Metrowerks only has wide char support for OS X >= 10.3 */
104 #if !defined(__DARWIN__) || \
105 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
106 #define wxHAVE_MWERKS_UNICODE
109 #ifdef wxHAVE_MWERKS_UNICODE
110 #define HAVE_WPRINTF 1
111 #define HAVE_WCSRTOMBS 1
112 #define HAVE_VSWPRINTF 1
114 #endif /* __MWERKS__ */
117 /* -------------------------------------------------------------------------
118 UTF-8 locale handling
119 ------------------------------------------------------------------------- */
122 #if wxUSE_UNICODE_UTF8
123 /* flag indicating whether the current locale uses UTF-8 or not; must be
124 updated every time the locale is changed! */
125 #if wxUSE_UTF8_LOCALE_ONLY
126 #define wxLocaleIsUtf8 true
128 extern WXDLLIMPEXP_BASE
bool wxLocaleIsUtf8
;
130 /* function used to update the flag: */
131 extern WXDLLIMPEXP_BASE
void wxUpdateLocaleIsUtf8();
132 #else /* !wxUSE_UNICODE_UTF8 */
133 inline void wxUpdateLocaleIsUtf8() {}
134 #endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */
135 #endif /* __cplusplus */
138 /* -------------------------------------------------------------------------
140 ------------------------------------------------------------------------- */
142 #define wxCRT_StrcatA strcat
143 #define wxCRT_StrchrA strchr
144 #define wxCRT_StrcmpA strcmp
145 #define wxCRT_StrcpyA strcpy
146 #define wxCRT_StrcspnA strcspn
147 #define wxCRT_StrlenA strlen
148 #define wxCRT_StrncatA strncat
149 #define wxCRT_StrncmpA strncmp
150 #define wxCRT_StrncpyA strncpy
151 #define wxCRT_StrpbrkA strpbrk
152 #define wxCRT_StrrchrA strrchr
153 #define wxCRT_StrspnA strspn
154 #define wxCRT_StrstrA strstr
156 #define wxCRT_StrcatW wcscat
157 #define wxCRT_StrchrW wcschr
158 #define wxCRT_StrcmpW wcscmp
159 #define wxCRT_StrcpyW wcscpy
160 #define wxCRT_StrcspnW wcscspn
161 #define wxCRT_StrncatW wcsncat
162 #define wxCRT_StrncmpW wcsncmp
163 #define wxCRT_StrncpyW wcsncpy
164 #define wxCRT_StrpbrkW wcspbrk
165 #define wxCRT_StrrchrW wcsrchr
166 #define wxCRT_StrspnW wcsspn
167 #define wxCRT_StrstrW wcsstr
169 /* these functions are not defined under CE, at least in VC8 CRT */
170 #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
171 #define wxCRT_StrcollA strcoll
172 #define wxCRT_StrxfrmA strxfrm
174 #define wxCRT_StrcollW wcscoll
175 #define wxCRT_StrxfrmW wcsxfrm
176 #endif /* __WXWINCE__ */
178 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under
179 Mac and VC++ for Windows CE don't provide it; additionally, gcc under
180 Mac and OpenVMS do not have wcsdup: */
181 #if defined(__VISUALC__) && __VISUALC__ >= 1400
182 #define wxCRT_StrdupA _strdup
183 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
184 #define wxCRT_StrdupA strdup
187 // all compilers except Cygwin provide _wcsdup() under Windows
188 #if defined(__WINDOWS__) && !defined(__CYGWIN__)
189 #define wxCRT_StrdupW _wcsdup
190 #elif defined(HAVE_WCSDUP)
191 #define wxCRT_StrdupW wcsdup
194 #ifdef wxHAVE_TCHAR_SUPPORT
195 /* we surely have wchar_t if we have TCHAR have wcslen() */
199 #endif /* wxHAVE_TCHAR_SUPPORT */
202 #define wxCRT_StrlenW wcslen
205 #define wxCRT_StrtodA strtod
206 #define wxCRT_StrtolA strtol
207 #define wxCRT_StrtoulA strtoul
208 #define wxCRT_StrtodW wcstod
209 #define wxCRT_StrtolW wcstol
210 #define wxCRT_StrtoulW wcstoul
213 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
214 #define wxCRT_StrtollA _strtoi64
215 #define wxCRT_StrtoullA _strtoui64
216 #define wxCRT_StrtollW _wcstoi64
217 #define wxCRT_StrtoullW _wcstoui64
221 #define wxCRT_StrtollA strtoll
222 #define wxCRT_StrtoullA strtoull
223 #endif /* HAVE_STRTOULL */
225 /* assume that we have wcstoull(), which is also C99, too */
226 #define wxCRT_StrtollW wcstoll
227 #define wxCRT_StrtoullW wcstoull
228 #endif /* HAVE_WCSTOULL */
231 /* Not all compilers have strnlen(); e.g. MSVC 6.x and 7.x don't have it */
232 #if wxCHECK_VISUALC_VERSION(8) || defined(HAVE_STRNLEN)
233 #define wxCRT_StrnlenA strnlen
236 #if wxCHECK_VISUALC_VERSION(8) || defined(HAVE_WCSNLEN)
237 #define wxCRT_StrnlenW wcsnlen
240 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
242 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
243 defined(__VISAGECPP__) || \
244 defined(__EMX__) || defined(__DJGPP__)
245 #define wxCRT_StricmpA stricmp
246 #define wxCRT_StrnicmpA strnicmp
247 #elif defined(__WXPALMOS__)
248 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
249 * quick hack should do until one can be written.
251 #define wxCRT_StricmpA StrCaselessCompare
252 #define wxCRT_StrnicmpA StrNCaselessCompare
253 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
254 (defined(__MWERKS__) && defined(__INTEL__))
255 #define wxCRT_StricmpA _stricmp
256 #define wxCRT_StrnicmpA _strnicmp
257 #elif defined(__UNIX__) || defined(__GNUWIN32__)
258 #define wxCRT_StricmpA strcasecmp
259 #define wxCRT_StrnicmpA strncasecmp
260 /* #else -- use wxWidgets implementation */
264 #define wxCRT_StricmpW _wcsicmp
265 #define wxCRT_StrnicmpW _wcsnicmp
266 #elif defined(__UNIX__)
267 #ifdef HAVE_WCSCASECMP
268 #define wxCRT_StricmpW wcscasecmp
270 #ifdef HAVE_WCSNCASECMP
271 #define wxCRT_StrnicmpW wcsncasecmp
273 /* #else -- use wxWidgets implementation */
277 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
279 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
281 /* these are extern "C" because they are used by regex lib: */
286 #ifndef wxCRT_StrlenW
287 WXDLLIMPEXP_BASE
size_t wxCRT_StrlenW(const wchar_t *s
);
290 #ifndef wxCRT_StrncmpW
291 WXDLLIMPEXP_BASE
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
);
298 /* FIXME-UTF8: remove this once we are Unicode only */
300 #define wxCRT_StrlenNative wxCRT_StrlenW
301 #define wxCRT_StrncmpNative wxCRT_StrncmpW
302 #define wxCRT_ToupperNative wxCRT_ToupperW
303 #define wxCRT_TolowerNative wxCRT_TolowerW
305 #define wxCRT_StrlenNative wxCRT_StrlenA
306 #define wxCRT_StrncmpNative wxCRT_StrncmpA
307 #define wxCRT_ToupperNative toupper
308 #define wxCRT_TolowerNative tolower
311 #ifndef wxCRT_StrcatW
312 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
);
315 #ifndef wxCRT_StrchrW
316 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
);
319 #ifndef wxCRT_StrcmpW
320 WXDLLIMPEXP_BASE
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
);
323 #ifndef wxCRT_StrcollW
324 WXDLLIMPEXP_BASE
int wxCRT_StrcollW(const wchar_t *s1
, const wchar_t *s2
);
327 #ifndef wxCRT_StrcpyW
328 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
);
331 #ifndef wxCRT_StrcspnW
332 WXDLLIMPEXP_BASE
size_t wxCRT_StrcspnW(const wchar_t *s
, const wchar_t *reject
);
335 #ifndef wxCRT_StrncatW
336 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
);
339 #ifndef wxCRT_StrncpyW
340 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
);
343 #ifndef wxCRT_StrpbrkW
344 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
);
347 #ifndef wxCRT_StrrchrW
348 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
);
351 #ifndef wxCRT_StrspnW
352 WXDLLIMPEXP_BASE
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
);
355 #ifndef wxCRT_StrstrW
356 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
);
359 #ifndef wxCRT_StrtodW
360 WXDLLIMPEXP_BASE
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
);
363 #ifndef wxCRT_StrtolW
364 WXDLLIMPEXP_BASE
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
367 #ifndef wxCRT_StrtoulW
368 WXDLLIMPEXP_BASE
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
371 #ifndef wxCRT_StrxfrmW
372 WXDLLIMPEXP_BASE
size_t wxCRT_StrxfrmW(wchar_t *dest
, const wchar_t *src
, size_t n
);
375 #ifndef wxCRT_StrdupA
376 WXDLLIMPEXP_BASE
char *wxCRT_StrdupA(const char *psz
);
379 #ifndef wxCRT_StrdupW
380 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrdupW(const wchar_t *pwz
);
383 #ifndef wxCRT_StricmpA
384 WXDLLIMPEXP_BASE
int wxCRT_StricmpA(const char *psz1
, const char *psz2
);
387 #ifndef wxCRT_StricmpW
388 WXDLLIMPEXP_BASE
int wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
);
391 #ifndef wxCRT_StrnicmpA
392 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpA(const char *psz1
, const char *psz2
, size_t len
);
395 #ifndef wxCRT_StrnicmpW
396 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpW(const wchar_t *psz1
, const wchar_t *psz2
, size_t len
);
399 #ifndef wxCRT_StrtokA
400 WXDLLIMPEXP_BASE
char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
);
403 #ifndef wxCRT_StrtokW
404 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
);
407 /* supply strtoll and strtoull, if needed */
409 #ifndef wxCRT_StrtollA
410 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollA(const char* nptr
,
413 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullA(const char* nptr
,
417 #ifndef wxCRT_StrtollW
418 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
,
421 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
,
425 #endif // wxLongLong_t
428 /* -------------------------------------------------------------------------
430 ------------------------------------------------------------------------- */
432 #if defined(__UNIX__) || defined(__WXMAC__) || defined(__WXPALMOS__)
439 /* these functions are only needed in the form used for filenames (i.e. char*
440 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
441 #if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */
443 #define wxCRT_Fopen fopen
444 #define wxCRT_Freopen freopen
445 #define wxCRT_Remove remove
446 #define wxCRT_Rename rename
448 #else /* Unicode filenames */
449 /* special case: these functions are missing under Win9x with Unicows so we
450 have to implement them ourselves */
451 #if wxUSE_UNICODE_MSLU
452 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfopen(const wchar_t *name
, const wchar_t *mode
);
453 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfreopen(const wchar_t *name
, const wchar_t *mode
, FILE *stream
);
454 WXDLLIMPEXP_BASE
int wxMSLU__wrename(const wchar_t *oldname
, const wchar_t *newname
);
455 WXDLLIMPEXP_BASE
int wxMSLU__wremove(const wchar_t *name
);
456 #define wxCRT_Fopen wxMSLU__wfopen
457 #define wxCRT_Freopen wxMSLU__wfreopen
458 #define wxCRT_Remove wxMSLU__wremove
459 #define wxCRT_Rename wxMSLU__wrename
461 /* WinCE CRT doesn't provide these functions so use our own */
463 WXDLLIMPEXP_BASE
int wxCRT_Rename(const wchar_t *src
,
465 WXDLLIMPEXP_BASE
int wxCRT_Remove(const wchar_t *path
);
467 #define wxCRT_Rename _wrename
468 #define wxCRT_Remove _wremove
470 #define wxCRT_Fopen _wfopen
471 #define wxCRT_Freopen _wfreopen
474 #endif /* wxMBFILES/!wxMBFILES */
476 #define wxCRT_PutsA puts
477 #define wxCRT_FputsA fputs
478 #define wxCRT_FgetsA fgets
479 #define wxCRT_FputcA fputc
480 #define wxCRT_FgetcA fgetc
481 #define wxCRT_UngetcA ungetc
483 #ifdef wxHAVE_TCHAR_SUPPORT
484 #define wxCRT_PutsW _putws
485 #define wxCRT_FputsW fputws
486 #define wxCRT_FputcW fputwc
489 #define wxCRT_FputsW fputws
492 #define wxCRT_PutsW putws
495 #define wxCRT_FputcW fputwc
497 #define wxCRT_FgetsW fgetws
500 WXDLLIMPEXP_BASE
int wxCRT_PutsW(const wchar_t *ws
);
504 WXDLLIMPEXP_BASE
int wxCRT_FputsW(const wchar_t *ch
, FILE *stream
);
508 WXDLLIMPEXP_BASE
int wxCRT_FputcW(wchar_t wc
, FILE *stream
);
512 NB: tmpnam() is unsafe and thus is not wrapped!
513 Use other wxWidgets facilities instead:
514 wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream
516 #define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead
518 /* FIXME-CE: provide our own perror() using ::GetLastError() */
521 #define wxCRT_PerrorA perror
522 #ifdef wxHAVE_TCHAR_SUPPORT
523 #define wxCRT_PerrorW _wperror
526 #endif /* !__WXWINCE__ */
528 /* -------------------------------------------------------------------------
530 ------------------------------------------------------------------------- */
532 /* there are no env vars at all under CE, so no _tgetenv neither */
534 /* can't define as inline function as this is a C file... */
535 #define wxCRT_GetenvA(name) (name, NULL)
536 #define wxCRT_GetenvW(name) (name, NULL)
538 #define wxCRT_GetenvA getenv
540 #define wxCRT_GetenvW _wgetenv
544 #ifndef wxCRT_GetenvW
545 WXDLLIMPEXP_BASE
wchar_t * wxCRT_GetenvW(const wchar_t *name
);
549 #define wxCRT_SystemA system
550 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
551 #if defined(_tsystem)
552 #define wxCRT_SystemW _wsystem
555 #define wxCRT_AtofA atof
556 #define wxCRT_AtoiA atoi
557 #define wxCRT_AtolA atol
559 #if defined(__MWERKS__)
561 #define wxCRT_AtofW watof
562 #define wxCRT_AtoiW watoi
563 #define wxCRT_AtolW watol
564 /* else: use ANSI versions */
566 #elif defined(wxHAVE_TCHAR_SUPPORT)
567 #define wxCRT_AtoiW _wtoi
568 #define wxCRT_AtolW _wtol
569 /* _wtof doesn't exist */
572 #define wxCRT_AtofW(s) wcstod(s, NULL)
574 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
575 /* wcstoi doesn't exist */
579 There are 2 unrelated problems with these functions under Mac:
580 a) Metrowerks MSL CRT implements them strictly in C99 sense and
581 doesn't support (very common) extension of allowing to call
582 mbstowcs(NULL, ...) which makes it pretty useless as you can't
583 know the size of the needed buffer
584 b) OS X <= 10.2 declares and even defined these functions but
585 doesn't really implement them -- they always return an error
587 So use our own replacements in both cases.
589 #if defined(__MWERKS__) && defined(__MSL__)
590 #define wxNEED_WX_MBSTOWCS
592 #if defined(__WXPALMOS__)
593 #define wxNEED_WX_MBSTOWCS
597 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
598 #define wxNEED_WX_MBSTOWCS
602 #ifdef wxNEED_WX_MBSTOWCS
603 /* even though they are defined and "implemented", they are bad and just
604 stubs so we need our own - we need these even in ANSI builds!! */
605 WXDLLIMPEXP_BASE
size_t wxMbstowcs(wchar_t *, const char *, size_t);
606 WXDLLIMPEXP_BASE
size_t wxWcstombs(char *, const wchar_t *, size_t);
608 #define wxMbstowcs mbstowcs
609 #define wxWcstombs wcstombs
614 /* -------------------------------------------------------------------------
616 ------------------------------------------------------------------------- */
618 #define wxCRT_StrftimeA strftime
620 /* FIXME-UTF8: when is this available? */
621 #define wxCRT_StrftimeW wcsftime
622 #endif /* ! __WXPALMOS__ */
624 #ifndef wxCRT_StrftimeW
625 WXDLLIMPEXP_BASE
size_t wxCRT_StrftimeW(wchar_t *s
, size_t max
,
627 const struct tm
*tm
);
632 /* -------------------------------------------------------------------------
634 ------------------------------------------------------------------------- */
637 #define WXWCHAR_T_CAST(c) (wint_t)(c)
639 #define WXWCHAR_T_CAST(c) c
642 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
643 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
644 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
645 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
646 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
647 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
648 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
649 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
650 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
651 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
652 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
655 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
656 /* /usr/include/wctype.h incorrectly declares translations */
657 /* tables which provokes tons of compile-time warnings -- try */
658 /* to correct this */
659 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
660 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
661 #else /* !glibc 2.0 */
662 #define wxCRT_TolowerW towlower
663 #define wxCRT_ToupperW towupper
665 #else /* !__GLIBC__ */
666 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
667 with signed chars < 0, so "fix" it here. */
668 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
669 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
670 #endif /* __GLIBC__/!__GLIBC__ */
676 /* -------------------------------------------------------------------------
677 wx wrappers for CRT functions in both char* and wchar_t* versions
678 ------------------------------------------------------------------------- */
682 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
683 * for buffer.h and stringimpl.h (both of which must be included before
684 * string.h, which is required by wxcrt.h) to have them here: */
686 /* safe version of strlen() (returns 0 if passed NULL pointer) */
687 inline size_t wxStrlen(const char *s
) { return s
? wxCRT_StrlenA(s
) : 0; }
688 inline size_t wxStrlen(const wchar_t *s
) { return s
? wxCRT_StrlenW(s
) : 0; }
689 #ifndef wxWCHAR_T_IS_WXCHAR16
690 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar16
*s
);
692 #ifndef wxWCHAR_T_IS_WXCHAR32
693 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar32
*s
);
695 #define wxWcslen wxCRT_StrlenW
697 #define wxStrdupA wxCRT_StrdupA
698 #define wxStrdupW wxCRT_StrdupW
699 inline char* wxStrdup(const char *s
) { return wxCRT_StrdupA(s
); }
700 inline wchar_t* wxStrdup(const wchar_t *s
) { return wxCRT_StrdupW(s
); }
701 #ifndef wxWCHAR_T_IS_WXCHAR16
702 WXDLLIMPEXP_BASE wxChar16
* wxStrdup(const wxChar16
* s
);
704 #ifndef wxWCHAR_T_IS_WXCHAR32
705 WXDLLIMPEXP_BASE wxChar32
* wxStrdup(const wxChar32
* s
);
708 #endif /* __cplusplus */
710 #endif /* _WX_WXCRTBASE_H_ */