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
41 #if defined(__WINDOWS__) && !defined(__WXWINCE__)
45 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
46 char *strtok_r(char *, const char *, char **);
50 Using -std=c++{98,0x} option with mingw32 disables most of standard
51 library extensions, so we can't rely on the presence of common non-ANSI
52 functions, define a special symbol to test for this. Notice that this
53 doesn't need to be done for g++ under Linux where _GNU_SOURCE (which is
54 defined by default) still makes all common extensions available even in
57 #if defined(__MINGW32__) && defined(__STRICT_ANSI__)
58 #define __WX_STRICT_ANSI_GCC__
62 a few compilers don't have the (non standard but common) isascii function,
63 define it ourselves for them
66 #if defined(__WX_STRICT_ANSI_GCC__)
67 #define wxNEED_ISASCII
68 #elif defined(_WIN32_WCE)
70 #define wxNEED_ISASCII
76 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
81 #define isspace(c) ((c) == wxT(' ') || (c) == wxT('\t'))
83 #endif /* _WIN32_WCE */
85 /* string.h functions */
87 #if defined(__WXWINCE__)
95 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
98 /* missing functions in some WinCE versions */
100 #if (_WIN32_WCE < 300)
101 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
103 #endif /* _WIN32_WCE */
106 /* -------------------------------------------------------------------------
107 UTF-8 locale handling
108 ------------------------------------------------------------------------- */
111 #if wxUSE_UNICODE_UTF8
112 /* flag indicating whether the current locale uses UTF-8 or not; must be
113 updated every time the locale is changed! */
114 #if wxUSE_UTF8_LOCALE_ONLY
115 #define wxLocaleIsUtf8 true
117 extern WXDLLIMPEXP_BASE
bool wxLocaleIsUtf8
;
119 /* function used to update the flag: */
120 extern WXDLLIMPEXP_BASE
void wxUpdateLocaleIsUtf8();
121 #else /* !wxUSE_UNICODE_UTF8 */
122 inline void wxUpdateLocaleIsUtf8() {}
123 #endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */
124 #endif /* __cplusplus */
127 /* -------------------------------------------------------------------------
129 ------------------------------------------------------------------------- */
131 #define wxCRT_StrcatA strcat
132 #define wxCRT_StrchrA strchr
133 #define wxCRT_StrcmpA strcmp
134 #define wxCRT_StrcpyA strcpy
135 #define wxCRT_StrcspnA strcspn
136 #define wxCRT_StrlenA strlen
137 #define wxCRT_StrncatA strncat
138 #define wxCRT_StrncmpA strncmp
139 #define wxCRT_StrncpyA strncpy
140 #define wxCRT_StrpbrkA strpbrk
141 #define wxCRT_StrrchrA strrchr
142 #define wxCRT_StrspnA strspn
143 #define wxCRT_StrstrA strstr
145 #define wxCRT_StrcatW wcscat
146 #define wxCRT_StrchrW wcschr
147 #define wxCRT_StrcmpW wcscmp
148 #define wxCRT_StrcpyW wcscpy
149 #define wxCRT_StrcspnW wcscspn
150 #define wxCRT_StrncatW wcsncat
151 #define wxCRT_StrncmpW wcsncmp
152 #define wxCRT_StrncpyW wcsncpy
153 #define wxCRT_StrpbrkW wcspbrk
154 #define wxCRT_StrrchrW wcsrchr
155 #define wxCRT_StrspnW wcsspn
156 #define wxCRT_StrstrW wcsstr
158 /* these functions are not defined under CE, at least in VC8 CRT */
159 #if !defined(__WXWINCE__)
160 #define wxCRT_StrcollA strcoll
161 #define wxCRT_StrxfrmA strxfrm
163 #define wxCRT_StrcollW wcscoll
164 #define wxCRT_StrxfrmW wcsxfrm
165 #endif /* __WXWINCE__ */
167 /* Almost all compilers have strdup(), but VC++ and MinGW call it _strdup().
168 And it's not available in MinGW strict ANSI mode nor under Windows CE. */
169 #if (defined(__VISUALC__) && __VISUALC__ >= 1400)
170 #define wxCRT_StrdupA _strdup
171 #elif defined(__MINGW32__)
172 #ifndef __WX_STRICT_ANSI_GCC__
173 #define wxCRT_StrdupA _strdup
175 #elif !defined(__WXWINCE__)
176 #define wxCRT_StrdupA strdup
179 /* most Windows compilers provide _wcsdup() */
180 #if defined(__WINDOWS__) && \
181 !(defined(__CYGWIN__) || defined(__WX_STRICT_ANSI_GCC__))
182 #define wxCRT_StrdupW _wcsdup
183 #elif defined(HAVE_WCSDUP)
184 #define wxCRT_StrdupW wcsdup
187 #ifdef wxHAVE_TCHAR_SUPPORT
188 /* we surely have wchar_t if we have TCHAR have wcslen() */
192 #endif /* wxHAVE_TCHAR_SUPPORT */
195 #define wxCRT_StrlenW wcslen
198 #define wxCRT_StrtodA strtod
199 #define wxCRT_StrtolA strtol
200 #define wxCRT_StrtoulA strtoul
201 #define wxCRT_StrtodW wcstod
202 #define wxCRT_StrtolW wcstol
203 #define wxCRT_StrtoulW wcstoul
206 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
207 #define wxCRT_StrtollA _strtoi64
208 #define wxCRT_StrtoullA _strtoui64
209 #define wxCRT_StrtollW _wcstoi64
210 #define wxCRT_StrtoullW _wcstoui64
214 #define wxCRT_StrtollA strtoll
215 #define wxCRT_StrtoullA strtoull
216 #endif /* HAVE_STRTOULL */
218 /* assume that we have wcstoull(), which is also C99, too */
219 #define wxCRT_StrtollW wcstoll
220 #define wxCRT_StrtoullW wcstoull
221 #endif /* HAVE_WCSTOULL */
225 Only VC8 and later provide strnlen() and wcsnlen() functions under Windows
226 and it's also only available starting from Windows CE 6.0 only in CE build.
228 #if wxCHECK_VISUALC_VERSION(8) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 0x600))
238 #define wxCRT_StrnlenA strnlen
242 #define wxCRT_StrnlenW wcsnlen
245 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
247 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
248 defined(__VISAGECPP__) || \
249 defined(__EMX__) || defined(__DJGPP__)
250 #define wxCRT_StricmpA stricmp
251 #define wxCRT_StrnicmpA strnicmp
252 #elif defined(__SYMANTEC__) || defined(__VISUALC__)
253 #define wxCRT_StricmpA _stricmp
254 #define wxCRT_StrnicmpA _strnicmp
255 #elif defined(__UNIX__) || (defined(__GNUWIN32__) && !defined(__WX_STRICT_ANSI_GCC__))
256 #define wxCRT_StricmpA strcasecmp
257 #define wxCRT_StrnicmpA strncasecmp
258 /* #else -- use wxWidgets implementation */
262 #define wxCRT_StricmpW _wcsicmp
263 #define wxCRT_StrnicmpW _wcsnicmp
264 #elif defined(__UNIX__)
265 #ifdef HAVE_WCSCASECMP
266 #define wxCRT_StricmpW wcscasecmp
268 #ifdef HAVE_WCSNCASECMP
269 #define wxCRT_StrnicmpW wcsncasecmp
271 /* #else -- use wxWidgets implementation */
275 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
277 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
279 /* these are extern "C" because they are used by regex lib: */
284 #ifndef wxCRT_StrlenW
285 WXDLLIMPEXP_BASE
size_t wxCRT_StrlenW(const wchar_t *s
);
288 #ifndef wxCRT_StrncmpW
289 WXDLLIMPEXP_BASE
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
);
296 /* FIXME-UTF8: remove this once we are Unicode only */
298 #define wxCRT_StrlenNative wxCRT_StrlenW
299 #define wxCRT_StrncmpNative wxCRT_StrncmpW
300 #define wxCRT_ToupperNative wxCRT_ToupperW
301 #define wxCRT_TolowerNative wxCRT_TolowerW
303 #define wxCRT_StrlenNative wxCRT_StrlenA
304 #define wxCRT_StrncmpNative wxCRT_StrncmpA
305 #define wxCRT_ToupperNative toupper
306 #define wxCRT_TolowerNative tolower
309 #ifndef wxCRT_StrcatW
310 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
);
313 #ifndef wxCRT_StrchrW
314 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
);
317 #ifndef wxCRT_StrcmpW
318 WXDLLIMPEXP_BASE
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
);
321 #ifndef wxCRT_StrcollW
322 WXDLLIMPEXP_BASE
int wxCRT_StrcollW(const wchar_t *s1
, const wchar_t *s2
);
325 #ifndef wxCRT_StrcpyW
326 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
);
329 #ifndef wxCRT_StrcspnW
330 WXDLLIMPEXP_BASE
size_t wxCRT_StrcspnW(const wchar_t *s
, const wchar_t *reject
);
333 #ifndef wxCRT_StrncatW
334 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
);
337 #ifndef wxCRT_StrncpyW
338 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
);
341 #ifndef wxCRT_StrpbrkW
342 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
);
345 #ifndef wxCRT_StrrchrW
346 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
);
349 #ifndef wxCRT_StrspnW
350 WXDLLIMPEXP_BASE
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
);
353 #ifndef wxCRT_StrstrW
354 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
);
357 #ifndef wxCRT_StrtodW
358 WXDLLIMPEXP_BASE
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
);
361 #ifndef wxCRT_StrtolW
362 WXDLLIMPEXP_BASE
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
365 #ifndef wxCRT_StrtoulW
366 WXDLLIMPEXP_BASE
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
369 #ifndef wxCRT_StrxfrmW
370 WXDLLIMPEXP_BASE
size_t wxCRT_StrxfrmW(wchar_t *dest
, const wchar_t *src
, size_t n
);
373 #ifndef wxCRT_StrdupA
374 WXDLLIMPEXP_BASE
char *wxCRT_StrdupA(const char *psz
);
377 #ifndef wxCRT_StrdupW
378 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrdupW(const wchar_t *pwz
);
381 #ifndef wxCRT_StricmpA
382 WXDLLIMPEXP_BASE
int wxCRT_StricmpA(const char *psz1
, const char *psz2
);
385 #ifndef wxCRT_StricmpW
386 WXDLLIMPEXP_BASE
int wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
);
389 #ifndef wxCRT_StrnicmpA
390 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpA(const char *psz1
, const char *psz2
, size_t len
);
393 #ifndef wxCRT_StrnicmpW
394 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpW(const wchar_t *psz1
, const wchar_t *psz2
, size_t len
);
397 #ifndef wxCRT_StrtokA
398 WXDLLIMPEXP_BASE
char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
);
401 #ifndef wxCRT_StrtokW
402 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
);
405 /* supply strtoll and strtoull, if needed */
407 #ifndef wxCRT_StrtollA
408 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollA(const char* nptr
,
411 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullA(const char* nptr
,
415 #ifndef wxCRT_StrtollW
416 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
,
419 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
,
423 #endif /* wxLongLong_t */
426 /* -------------------------------------------------------------------------
428 ------------------------------------------------------------------------- */
430 #if defined(__UNIX__) || defined(__WXMAC__)
437 /* these functions are only needed in the form used for filenames (i.e. char*
438 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
439 #if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */
441 #define wxCRT_Fopen fopen
442 #define wxCRT_Freopen freopen
443 #define wxCRT_Remove remove
444 #define wxCRT_Rename rename
446 #else /* Unicode filenames */
447 /* special case: these functions are missing under Win9x with Unicows so we
448 have to implement them ourselves */
449 #if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__)
450 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfopen(const wchar_t *name
, const wchar_t *mode
);
451 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfreopen(const wchar_t *name
, const wchar_t *mode
, FILE *stream
);
452 WXDLLIMPEXP_BASE
int wxMSLU__wrename(const wchar_t *oldname
, const wchar_t *newname
);
453 WXDLLIMPEXP_BASE
int wxMSLU__wremove(const wchar_t *name
);
454 #define wxCRT_Fopen wxMSLU__wfopen
455 #define wxCRT_Freopen wxMSLU__wfreopen
456 #define wxCRT_Remove wxMSLU__wremove
457 #define wxCRT_Rename wxMSLU__wrename
459 /* WinCE CRT doesn't provide these functions so use our own */
461 WXDLLIMPEXP_BASE
int wxCRT_Rename(const wchar_t *src
,
463 WXDLLIMPEXP_BASE
int wxCRT_Remove(const wchar_t *path
);
465 #define wxCRT_Rename _wrename
466 #define wxCRT_Remove _wremove
468 #define wxCRT_Fopen _wfopen
469 #define wxCRT_Freopen _wfreopen
472 #endif /* wxMBFILES/!wxMBFILES */
474 #define wxCRT_PutsA puts
475 #define wxCRT_FputsA fputs
476 #define wxCRT_FgetsA fgets
477 #define wxCRT_FputcA fputc
478 #define wxCRT_FgetcA fgetc
479 #define wxCRT_UngetcA ungetc
481 #ifdef wxHAVE_TCHAR_SUPPORT
482 #define wxCRT_PutsW _putws
483 #define wxCRT_FputsW fputws
484 #define wxCRT_FputcW fputwc
487 #define wxCRT_FputsW fputws
490 #define wxCRT_PutsW putws
493 #define wxCRT_FputcW fputwc
495 #define wxCRT_FgetsW fgetws
498 WXDLLIMPEXP_BASE
int wxCRT_PutsW(const wchar_t *ws
);
502 WXDLLIMPEXP_BASE
int wxCRT_FputsW(const wchar_t *ch
, FILE *stream
);
506 WXDLLIMPEXP_BASE
int wxCRT_FputcW(wchar_t wc
, FILE *stream
);
510 NB: tmpnam() is unsafe and thus is not wrapped!
511 Use other wxWidgets facilities instead:
512 wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream
514 #define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead
516 /* FIXME-CE: provide our own perror() using ::GetLastError() */
519 #define wxCRT_PerrorA perror
520 #ifdef wxHAVE_TCHAR_SUPPORT
521 #define wxCRT_PerrorW _wperror
524 #endif /* !__WXWINCE__ */
526 /* -------------------------------------------------------------------------
528 ------------------------------------------------------------------------- */
530 /* there are no env vars at all under CE, so no _tgetenv neither */
532 /* can't define as inline function as this is a C file... */
533 #define wxCRT_GetenvA(name) (name, NULL)
534 #define wxCRT_GetenvW(name) (name, NULL)
536 #define wxCRT_GetenvA getenv
538 #define wxCRT_GetenvW _wgetenv
542 #ifndef wxCRT_GetenvW
543 WXDLLIMPEXP_BASE
wchar_t * wxCRT_GetenvW(const wchar_t *name
);
547 #define wxCRT_SystemA system
548 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
549 #if defined(_tsystem)
550 #define wxCRT_SystemW _wsystem
553 #define wxCRT_AtofA atof
554 #define wxCRT_AtoiA atoi
555 #define wxCRT_AtolA atol
557 #if defined(wxHAVE_TCHAR_SUPPORT) && !defined(__WX_STRICT_ANSI_GCC__)
558 #define wxCRT_AtoiW _wtoi
559 #define wxCRT_AtolW _wtol
560 /* _wtof doesn't exist */
563 #define wxCRT_AtofW(s) wcstod(s, NULL)
565 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
566 /* wcstoi doesn't exist */
570 #if !defined(__WXOSX_IPHONE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
571 #define wxNEED_WX_MBSTOWCS
575 #ifdef wxNEED_WX_MBSTOWCS
576 /* even though they are defined and "implemented", they are bad and just
577 stubs so we need our own - we need these even in ANSI builds!! */
578 WXDLLIMPEXP_BASE
size_t wxMbstowcs(wchar_t *, const char *, size_t);
579 WXDLLIMPEXP_BASE
size_t wxWcstombs(char *, const wchar_t *, size_t);
581 #define wxMbstowcs mbstowcs
582 #define wxWcstombs wcstombs
587 /* -------------------------------------------------------------------------
589 ------------------------------------------------------------------------- */
591 #define wxCRT_StrftimeA strftime
594 IRIX provides not one but two versions of wcsftime(): XPG4 one which
595 uses "const char*" for the third parameter and so can't be used and the
596 correct, XPG5, one. Unfortunately we can't just define _XOPEN_SOURCE
597 high enough to get XPG5 version as this undefines other symbols which
598 make other functions we use unavailable (see <standards.h> for gory
599 details). So just declare the XPG5 version ourselves, we're extremely
600 unlikely to ever be compiled on a system without it. But if we ever do,
601 a configure test would need to be added for it (and _MIPS_SYMBOL_PRESENT
602 should be used to check for its presence during run-time, i.e. it would
603 probably be simpler to just always use our own wxCRT_StrftimeW() below
604 if it does ever become a problem).
610 _xpg5_wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm
* );
611 #define wxCRT_StrftimeW _xpg5_wcsftime
614 Assume it's always available under non-Unix systems as this does seem
615 to be the case for now. And under Unix we trust configure to detect it
616 (except for SGI special case above).
618 #if defined(HAVE_WCSFTIME) || !defined(__UNIX__)
619 #define wxCRT_StrftimeW wcsftime
623 #ifndef wxCRT_StrftimeW
624 WXDLLIMPEXP_BASE
size_t wxCRT_StrftimeW(wchar_t *s
, size_t max
,
626 const struct tm
*tm
);
631 /* -------------------------------------------------------------------------
633 ------------------------------------------------------------------------- */
636 #define WXWCHAR_T_CAST(c) (wint_t)(c)
638 #define WXWCHAR_T_CAST(c) c
641 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
642 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
643 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
644 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
645 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
646 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
647 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
648 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
649 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
650 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
651 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
654 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
655 /* /usr/include/wctype.h incorrectly declares translations */
656 /* tables which provokes tons of compile-time warnings -- try */
657 /* to correct this */
658 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
659 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
660 #else /* !glibc 2.0 */
661 #define wxCRT_TolowerW towlower
662 #define wxCRT_ToupperW towupper
664 #else /* !__GLIBC__ */
665 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
666 with signed chars < 0, so "fix" it here. */
667 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
668 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
669 #endif /* __GLIBC__/!__GLIBC__ */
675 /* -------------------------------------------------------------------------
676 wx wrappers for CRT functions in both char* and wchar_t* versions
677 ------------------------------------------------------------------------- */
681 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
682 * for buffer.h and stringimpl.h (both of which must be included before
683 * string.h, which is required by wxcrt.h) to have them here: */
685 /* safe version of strlen() (returns 0 if passed NULL pointer) */
686 inline size_t wxStrlen(const char *s
) { return s
? wxCRT_StrlenA(s
) : 0; }
687 inline size_t wxStrlen(const wchar_t *s
) { return s
? wxCRT_StrlenW(s
) : 0; }
688 #ifndef wxWCHAR_T_IS_WXCHAR16
689 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar16
*s
);
691 #ifndef wxWCHAR_T_IS_WXCHAR32
692 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar32
*s
);
694 #define wxWcslen wxCRT_StrlenW
696 #define wxStrdupA wxCRT_StrdupA
697 #define wxStrdupW wxCRT_StrdupW
698 inline char* wxStrdup(const char *s
) { return wxCRT_StrdupA(s
); }
699 inline wchar_t* wxStrdup(const wchar_t *s
) { return wxCRT_StrdupW(s
); }
700 #ifndef wxWCHAR_T_IS_WXCHAR16
701 WXDLLIMPEXP_BASE wxChar16
* wxStrdup(const wxChar16
* s
);
703 #ifndef wxWCHAR_T_IS_WXCHAR32
704 WXDLLIMPEXP_BASE wxChar32
* wxStrdup(const wxChar32
* s
);
707 #endif /* __cplusplus */
709 #endif /* _WX_WXCRTBASE_H_ */