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 compiler have strdup(), but VC++ for CE doesn't provide it.
168 Another special case is gcc in strict ANSI mode: normally it doesn't provide
169 strdup() but MinGW does provide it under MSVC-compatible name so test for it
170 before checking __WX_STRICT_ANSI_GCC__. */
171 #if (defined(__VISUALC__) && __VISUALC__ >= 1400) || \
173 #define wxCRT_StrdupA _strdup
174 #elif !(defined(__WXWINCE__) || defined(__WX_STRICT_ANSI_GCC__))
175 #define wxCRT_StrdupA strdup
178 /* most Windows compilers provide _wcsdup() */
179 #if defined(__WINDOWS__) && \
180 !(defined(__CYGWIN__) || defined(__WX_STRICT_ANSI_GCC__))
181 #define wxCRT_StrdupW _wcsdup
182 #elif defined(HAVE_WCSDUP)
183 #define wxCRT_StrdupW wcsdup
186 #ifdef wxHAVE_TCHAR_SUPPORT
187 /* we surely have wchar_t if we have TCHAR have wcslen() */
191 #endif /* wxHAVE_TCHAR_SUPPORT */
194 #define wxCRT_StrlenW wcslen
197 #define wxCRT_StrtodA strtod
198 #define wxCRT_StrtolA strtol
199 #define wxCRT_StrtoulA strtoul
200 #define wxCRT_StrtodW wcstod
201 #define wxCRT_StrtolW wcstol
202 #define wxCRT_StrtoulW wcstoul
205 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
206 #define wxCRT_StrtollA _strtoi64
207 #define wxCRT_StrtoullA _strtoui64
208 #define wxCRT_StrtollW _wcstoi64
209 #define wxCRT_StrtoullW _wcstoui64
213 #define wxCRT_StrtollA strtoll
214 #define wxCRT_StrtoullA strtoull
215 #endif /* HAVE_STRTOULL */
217 /* assume that we have wcstoull(), which is also C99, too */
218 #define wxCRT_StrtollW wcstoll
219 #define wxCRT_StrtoullW wcstoull
220 #endif /* HAVE_WCSTOULL */
224 Only VC8 and later provide strnlen() and wcsnlen() functions under Windows
225 and it's also only available starting from Windows CE 6.0 only in CE build.
227 #if wxCHECK_VISUALC_VERSION(8) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 0x600))
237 #define wxCRT_StrnlenA strnlen
241 #define wxCRT_StrnlenW wcsnlen
244 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
246 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
247 defined(__VISAGECPP__) || \
248 defined(__EMX__) || defined(__DJGPP__)
249 #define wxCRT_StricmpA stricmp
250 #define wxCRT_StrnicmpA strnicmp
251 #elif defined(__SYMANTEC__) || defined(__VISUALC__)
252 #define wxCRT_StricmpA _stricmp
253 #define wxCRT_StrnicmpA _strnicmp
254 #elif defined(__UNIX__) || (defined(__GNUWIN32__) && !defined(__WX_STRICT_ANSI_GCC__))
255 #define wxCRT_StricmpA strcasecmp
256 #define wxCRT_StrnicmpA strncasecmp
257 /* #else -- use wxWidgets implementation */
261 #define wxCRT_StricmpW _wcsicmp
262 #define wxCRT_StrnicmpW _wcsnicmp
263 #elif defined(__UNIX__)
264 #ifdef HAVE_WCSCASECMP
265 #define wxCRT_StricmpW wcscasecmp
267 #ifdef HAVE_WCSNCASECMP
268 #define wxCRT_StrnicmpW wcsncasecmp
270 /* #else -- use wxWidgets implementation */
274 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
276 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
278 /* these are extern "C" because they are used by regex lib: */
283 #ifndef wxCRT_StrlenW
284 WXDLLIMPEXP_BASE
size_t wxCRT_StrlenW(const wchar_t *s
);
287 #ifndef wxCRT_StrncmpW
288 WXDLLIMPEXP_BASE
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
);
295 /* FIXME-UTF8: remove this once we are Unicode only */
297 #define wxCRT_StrlenNative wxCRT_StrlenW
298 #define wxCRT_StrncmpNative wxCRT_StrncmpW
299 #define wxCRT_ToupperNative wxCRT_ToupperW
300 #define wxCRT_TolowerNative wxCRT_TolowerW
302 #define wxCRT_StrlenNative wxCRT_StrlenA
303 #define wxCRT_StrncmpNative wxCRT_StrncmpA
304 #define wxCRT_ToupperNative toupper
305 #define wxCRT_TolowerNative tolower
308 #ifndef wxCRT_StrcatW
309 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
);
312 #ifndef wxCRT_StrchrW
313 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
);
316 #ifndef wxCRT_StrcmpW
317 WXDLLIMPEXP_BASE
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
);
320 #ifndef wxCRT_StrcollW
321 WXDLLIMPEXP_BASE
int wxCRT_StrcollW(const wchar_t *s1
, const wchar_t *s2
);
324 #ifndef wxCRT_StrcpyW
325 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
);
328 #ifndef wxCRT_StrcspnW
329 WXDLLIMPEXP_BASE
size_t wxCRT_StrcspnW(const wchar_t *s
, const wchar_t *reject
);
332 #ifndef wxCRT_StrncatW
333 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
);
336 #ifndef wxCRT_StrncpyW
337 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
);
340 #ifndef wxCRT_StrpbrkW
341 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
);
344 #ifndef wxCRT_StrrchrW
345 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
);
348 #ifndef wxCRT_StrspnW
349 WXDLLIMPEXP_BASE
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
);
352 #ifndef wxCRT_StrstrW
353 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
);
356 #ifndef wxCRT_StrtodW
357 WXDLLIMPEXP_BASE
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
);
360 #ifndef wxCRT_StrtolW
361 WXDLLIMPEXP_BASE
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
364 #ifndef wxCRT_StrtoulW
365 WXDLLIMPEXP_BASE
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
368 #ifndef wxCRT_StrxfrmW
369 WXDLLIMPEXP_BASE
size_t wxCRT_StrxfrmW(wchar_t *dest
, const wchar_t *src
, size_t n
);
372 #ifndef wxCRT_StrdupA
373 WXDLLIMPEXP_BASE
char *wxCRT_StrdupA(const char *psz
);
376 #ifndef wxCRT_StrdupW
377 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrdupW(const wchar_t *pwz
);
380 #ifndef wxCRT_StricmpA
381 WXDLLIMPEXP_BASE
int wxCRT_StricmpA(const char *psz1
, const char *psz2
);
384 #ifndef wxCRT_StricmpW
385 WXDLLIMPEXP_BASE
int wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
);
388 #ifndef wxCRT_StrnicmpA
389 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpA(const char *psz1
, const char *psz2
, size_t len
);
392 #ifndef wxCRT_StrnicmpW
393 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpW(const wchar_t *psz1
, const wchar_t *psz2
, size_t len
);
396 #ifndef wxCRT_StrtokA
397 WXDLLIMPEXP_BASE
char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
);
400 #ifndef wxCRT_StrtokW
401 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
);
404 /* supply strtoll and strtoull, if needed */
406 #ifndef wxCRT_StrtollA
407 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollA(const char* nptr
,
410 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullA(const char* nptr
,
414 #ifndef wxCRT_StrtollW
415 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
,
418 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
,
422 #endif /* wxLongLong_t */
425 /* -------------------------------------------------------------------------
427 ------------------------------------------------------------------------- */
429 #if defined(__UNIX__) || defined(__WXMAC__)
436 /* these functions are only needed in the form used for filenames (i.e. char*
437 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
438 #if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */
440 #define wxCRT_Fopen fopen
441 #define wxCRT_Freopen freopen
442 #define wxCRT_Remove remove
443 #define wxCRT_Rename rename
445 #else /* Unicode filenames */
446 /* special case: these functions are missing under Win9x with Unicows so we
447 have to implement them ourselves */
448 #if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__)
449 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfopen(const wchar_t *name
, const wchar_t *mode
);
450 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfreopen(const wchar_t *name
, const wchar_t *mode
, FILE *stream
);
451 WXDLLIMPEXP_BASE
int wxMSLU__wrename(const wchar_t *oldname
, const wchar_t *newname
);
452 WXDLLIMPEXP_BASE
int wxMSLU__wremove(const wchar_t *name
);
453 #define wxCRT_Fopen wxMSLU__wfopen
454 #define wxCRT_Freopen wxMSLU__wfreopen
455 #define wxCRT_Remove wxMSLU__wremove
456 #define wxCRT_Rename wxMSLU__wrename
458 /* WinCE CRT doesn't provide these functions so use our own */
460 WXDLLIMPEXP_BASE
int wxCRT_Rename(const wchar_t *src
,
462 WXDLLIMPEXP_BASE
int wxCRT_Remove(const wchar_t *path
);
464 #define wxCRT_Rename _wrename
465 #define wxCRT_Remove _wremove
467 #define wxCRT_Fopen _wfopen
468 #define wxCRT_Freopen _wfreopen
471 #endif /* wxMBFILES/!wxMBFILES */
473 #define wxCRT_PutsA puts
474 #define wxCRT_FputsA fputs
475 #define wxCRT_FgetsA fgets
476 #define wxCRT_FputcA fputc
477 #define wxCRT_FgetcA fgetc
478 #define wxCRT_UngetcA ungetc
480 #ifdef wxHAVE_TCHAR_SUPPORT
481 #define wxCRT_PutsW _putws
482 #define wxCRT_FputsW fputws
483 #define wxCRT_FputcW fputwc
486 #define wxCRT_FputsW fputws
489 #define wxCRT_PutsW putws
492 #define wxCRT_FputcW fputwc
494 #define wxCRT_FgetsW fgetws
497 WXDLLIMPEXP_BASE
int wxCRT_PutsW(const wchar_t *ws
);
501 WXDLLIMPEXP_BASE
int wxCRT_FputsW(const wchar_t *ch
, FILE *stream
);
505 WXDLLIMPEXP_BASE
int wxCRT_FputcW(wchar_t wc
, FILE *stream
);
509 NB: tmpnam() is unsafe and thus is not wrapped!
510 Use other wxWidgets facilities instead:
511 wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream
513 #define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead
515 /* FIXME-CE: provide our own perror() using ::GetLastError() */
518 #define wxCRT_PerrorA perror
519 #ifdef wxHAVE_TCHAR_SUPPORT
520 #define wxCRT_PerrorW _wperror
523 #endif /* !__WXWINCE__ */
525 /* -------------------------------------------------------------------------
527 ------------------------------------------------------------------------- */
529 /* there are no env vars at all under CE, so no _tgetenv neither */
531 /* can't define as inline function as this is a C file... */
532 #define wxCRT_GetenvA(name) (name, NULL)
533 #define wxCRT_GetenvW(name) (name, NULL)
535 #define wxCRT_GetenvA getenv
537 #define wxCRT_GetenvW _wgetenv
541 #ifndef wxCRT_GetenvW
542 WXDLLIMPEXP_BASE
wchar_t * wxCRT_GetenvW(const wchar_t *name
);
546 #define wxCRT_SystemA system
547 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
548 #if defined(_tsystem)
549 #define wxCRT_SystemW _wsystem
552 #define wxCRT_AtofA atof
553 #define wxCRT_AtoiA atoi
554 #define wxCRT_AtolA atol
556 #if defined(wxHAVE_TCHAR_SUPPORT) && !defined(__WX_STRICT_ANSI_GCC__)
557 #define wxCRT_AtoiW _wtoi
558 #define wxCRT_AtolW _wtol
559 /* _wtof doesn't exist */
562 #define wxCRT_AtofW(s) wcstod(s, NULL)
564 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
565 /* wcstoi doesn't exist */
569 #if !defined(__WXOSX_IPHONE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
570 #define wxNEED_WX_MBSTOWCS
574 #ifdef wxNEED_WX_MBSTOWCS
575 /* even though they are defined and "implemented", they are bad and just
576 stubs so we need our own - we need these even in ANSI builds!! */
577 WXDLLIMPEXP_BASE
size_t wxMbstowcs(wchar_t *, const char *, size_t);
578 WXDLLIMPEXP_BASE
size_t wxWcstombs(char *, const wchar_t *, size_t);
580 #define wxMbstowcs mbstowcs
581 #define wxWcstombs wcstombs
586 /* -------------------------------------------------------------------------
588 ------------------------------------------------------------------------- */
590 #define wxCRT_StrftimeA strftime
593 IRIX provides not one but two versions of wcsftime(): XPG4 one which
594 uses "const char*" for the third parameter and so can't be used and the
595 correct, XPG5, one. Unfortunately we can't just define _XOPEN_SOURCE
596 high enough to get XPG5 version as this undefines other symbols which
597 make other functions we use unavailable (see <standards.h> for gory
598 details). So just declare the XPG5 version ourselves, we're extremely
599 unlikely to ever be compiled on a system without it. But if we ever do,
600 a configure test would need to be added for it (and _MIPS_SYMBOL_PRESENT
601 should be used to check for its presence during run-time, i.e. it would
602 probably be simpler to just always use our own wxCRT_StrftimeW() below
603 if it does ever become a problem).
609 _xpg5_wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm
* );
610 #define wxCRT_StrftimeW _xpg5_wcsftime
613 Assume it's always available under non-Unix systems as this does seem
614 to be the case for now. And under Unix we trust configure to detect it
615 (except for SGI special case above).
617 #if defined(HAVE_WCSFTIME) || !defined(__UNIX__)
618 #define wxCRT_StrftimeW wcsftime
622 #ifndef wxCRT_StrftimeW
623 WXDLLIMPEXP_BASE
size_t wxCRT_StrftimeW(wchar_t *s
, size_t max
,
625 const struct tm
*tm
);
630 /* -------------------------------------------------------------------------
632 ------------------------------------------------------------------------- */
635 #define WXWCHAR_T_CAST(c) (wint_t)(c)
637 #define WXWCHAR_T_CAST(c) c
640 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
641 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
642 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
643 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
644 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
645 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
646 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
647 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
648 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
649 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
650 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
653 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
654 /* /usr/include/wctype.h incorrectly declares translations */
655 /* tables which provokes tons of compile-time warnings -- try */
656 /* to correct this */
657 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
658 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
659 #else /* !glibc 2.0 */
660 #define wxCRT_TolowerW towlower
661 #define wxCRT_ToupperW towupper
663 #else /* !__GLIBC__ */
664 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
665 with signed chars < 0, so "fix" it here. */
666 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
667 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
668 #endif /* __GLIBC__/!__GLIBC__ */
674 /* -------------------------------------------------------------------------
675 wx wrappers for CRT functions in both char* and wchar_t* versions
676 ------------------------------------------------------------------------- */
680 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
681 * for buffer.h and stringimpl.h (both of which must be included before
682 * string.h, which is required by wxcrt.h) to have them here: */
684 /* safe version of strlen() (returns 0 if passed NULL pointer) */
685 inline size_t wxStrlen(const char *s
) { return s
? wxCRT_StrlenA(s
) : 0; }
686 inline size_t wxStrlen(const wchar_t *s
) { return s
? wxCRT_StrlenW(s
) : 0; }
687 #ifndef wxWCHAR_T_IS_WXCHAR16
688 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar16
*s
);
690 #ifndef wxWCHAR_T_IS_WXCHAR32
691 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar32
*s
);
693 #define wxWcslen wxCRT_StrlenW
695 #define wxStrdupA wxCRT_StrdupA
696 #define wxStrdupW wxCRT_StrdupW
697 inline char* wxStrdup(const char *s
) { return wxCRT_StrdupA(s
); }
698 inline wchar_t* wxStrdup(const wchar_t *s
) { return wxCRT_StrdupW(s
); }
699 #ifndef wxWCHAR_T_IS_WXCHAR16
700 WXDLLIMPEXP_BASE wxChar16
* wxStrdup(const wxChar16
* s
);
702 #ifndef wxWCHAR_T_IS_WXCHAR32
703 WXDLLIMPEXP_BASE wxChar32
* wxStrdup(const wxChar32
* s
);
706 #endif /* __cplusplus */
708 #endif /* _WX_WXCRTBASE_H_ */