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
31 #if !defined(__WXPALMOS5__)
35 #if defined(__WXPALMOS__)
43 #if defined(__WINDOWS__) && !defined(__WXWINCE__)
47 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
48 char *strtok_r(char *, const char *, char **);
52 a few compilers don't have the (non standard but common) isascii function,
53 define it ourselves for them
56 #if defined(__MWERKS__)
57 #define wxNEED_ISASCII
58 #elif defined(_WIN32_WCE)
60 #define wxNEED_ISASCII
66 inline int isascii(int c
) { return (unsigned)c
< 0x80; }
71 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
73 #endif /* _WIN32_WCE */
75 /* string.h functions */
77 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
79 #elif defined(__WXWINCE__)
87 WXDLLIMPEXP_BASE
char *strdup(const char* s
);
90 /* missing functions in some WinCE versions */
92 #if (_WIN32_WCE < 300)
93 WXDLLIMPEXP_BASE
void *calloc( size_t num
, size_t size
);
95 #endif /* _WIN32_WCE */
98 #if defined(__MWERKS__)
99 /* Metrowerks only has wide char support for OS X >= 10.3 */
100 #if !defined(__DARWIN__) || \
101 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
102 #define wxHAVE_MWERKS_UNICODE
105 #ifdef wxHAVE_MWERKS_UNICODE
106 #define HAVE_WPRINTF 1
107 #define HAVE_WCSRTOMBS 1
108 #define HAVE_VSWPRINTF 1
110 #endif /* __MWERKS__ */
113 /* -------------------------------------------------------------------------
114 UTF-8 locale handling
115 ------------------------------------------------------------------------- */
118 #if wxUSE_UNICODE_UTF8
119 /* flag indicating whether the current locale uses UTF-8 or not; must be
120 updated every time the locale is changed! */
121 #if wxUSE_UTF8_LOCALE_ONLY
122 #define wxLocaleIsUtf8 true
124 extern WXDLLIMPEXP_BASE
bool wxLocaleIsUtf8
;
126 /* function used to update the flag: */
127 extern WXDLLIMPEXP_BASE
void wxUpdateLocaleIsUtf8();
128 #else /* !wxUSE_UNICODE_UTF8 */
129 inline void wxUpdateLocaleIsUtf8() {}
130 #endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */
131 #endif /* __cplusplus */
134 /* -------------------------------------------------------------------------
136 ------------------------------------------------------------------------- */
138 #define wxCRT_StrcatA strcat
139 #define wxCRT_StrchrA strchr
140 #define wxCRT_StrcmpA strcmp
141 #define wxCRT_StrcpyA strcpy
142 #define wxCRT_StrcspnA strcspn
143 #define wxCRT_StrlenA strlen
144 #define wxCRT_StrncatA strncat
145 #define wxCRT_StrncmpA strncmp
146 #define wxCRT_StrncpyA strncpy
147 #define wxCRT_StrpbrkA strpbrk
148 #define wxCRT_StrrchrA strrchr
149 #define wxCRT_StrspnA strspn
150 #define wxCRT_StrstrA strstr
152 #define wxCRT_StrcatW wcscat
153 #define wxCRT_StrchrW wcschr
154 #define wxCRT_StrcmpW wcscmp
155 #define wxCRT_StrcpyW wcscpy
156 #define wxCRT_StrcspnW wcscspn
157 #define wxCRT_StrncatW wcsncat
158 #define wxCRT_StrncmpW wcsncmp
159 #define wxCRT_StrncpyW wcsncpy
160 #define wxCRT_StrpbrkW wcspbrk
161 #define wxCRT_StrrchrW wcsrchr
162 #define wxCRT_StrspnW wcsspn
163 #define wxCRT_StrstrW wcsstr
165 /* these functions are not defined under CE, at least in VC8 CRT */
166 #if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
167 #define wxCRT_StrcollA strcoll
168 #define wxCRT_StrxfrmA strxfrm
170 #define wxCRT_StrcollW wcscoll
171 #define wxCRT_StrxfrmW wcsxfrm
172 #endif /* __WXWINCE__ */
174 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under
175 Mac and VC++ for Windows CE don't provide it; additionally, gcc under
176 Mac and OpenVMS do not have wcsdup: */
177 #if defined(__VISUALC__) && __VISUALC__ >= 1400
178 #define wxCRT_StrdupA _strdup
179 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
180 #define wxCRT_StrdupA strdup
182 #if defined(__WINDOWS__)
183 #define wxCRT_StrdupW _wcsdup
184 #elif defined(HAVE_WCSDUP)
185 #define wxCRT_StrdupW wcsdup
188 #ifdef wxHAVE_TCHAR_SUPPORT
189 /* we surely have wchar_t if we have TCHAR have wcslen() */
193 #endif /* wxHAVE_TCHAR_SUPPORT */
196 #define wxCRT_StrlenW wcslen
199 #define wxCRT_StrtodA strtod
200 #define wxCRT_StrtolA strtol
201 #define wxCRT_StrtoulA strtoul
202 #define wxCRT_StrtodW wcstod
203 #define wxCRT_StrtolW wcstol
204 #define wxCRT_StrtoulW wcstoul
207 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
208 #define wxCRT_StrtollA _strtoi64
209 #define wxCRT_StrtoullA _strtoui64
210 #define wxCRT_StrtollW _wcstoi64
211 #define wxCRT_StrtoullW _wcstoui64
215 #define wxCRT_StrtollA strtoll
216 #define wxCRT_StrtoullA strtoull
217 #endif /* HAVE_STRTOULL */
219 /* assume that we have wcstoull(), which is also C99, too */
220 #define wxCRT_StrtollW wcstoll
221 #define wxCRT_StrtoullW wcstoull
222 #endif /* HAVE_WCSTOULL */
225 /* Not all compilers have strnlen(); e.g. MSVC 6.x and 7.x don't have it */
226 #if wxCHECK_VISUALC_VERSION(8) || defined(HAVE_STRNLEN)
227 #define wxCRT_StrnlenA strnlen
230 #if wxCHECK_VISUALC_VERSION(8) || defined(HAVE_WCSNLEN)
231 #define wxCRT_StrnlenW wcsnlen
234 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
236 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
237 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 StrNCaselessCompare
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 */
258 #define wxCRT_StricmpW _wcsicmp
259 #define wxCRT_StrnicmpW _wcsnicmp
260 #elif defined(__UNIX__)
261 #ifdef HAVE_WCSCASECMP
262 #define wxCRT_StricmpW wcscasecmp
264 #ifdef HAVE_WCSNCASECMP
265 #define wxCRT_StrnicmpW wcsncasecmp
267 /* #else -- use wxWidgets implementation */
271 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
273 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
275 /* these are extern "C" because they are used by regex lib: */
280 #ifndef wxCRT_StrlenW
281 WXDLLIMPEXP_BASE
size_t wxCRT_StrlenW(const wchar_t *s
);
284 #ifndef wxCRT_StrncmpW
285 WXDLLIMPEXP_BASE
int wxCRT_StrncmpW(const wchar_t *s1
, const wchar_t *s2
, size_t n
);
292 /* FIXME-UTF8: remove this once we are Unicode only */
294 #define wxCRT_StrlenNative wxCRT_StrlenW
295 #define wxCRT_StrncmpNative wxCRT_StrncmpW
296 #define wxCRT_ToupperNative wxCRT_ToupperW
297 #define wxCRT_TolowerNative wxCRT_TolowerW
299 #define wxCRT_StrlenNative wxCRT_StrlenA
300 #define wxCRT_StrncmpNative wxCRT_StrncmpA
301 #define wxCRT_ToupperNative toupper
302 #define wxCRT_TolowerNative tolower
305 #ifndef wxCRT_StrcatW
306 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcatW(wchar_t *dest
, const wchar_t *src
);
309 #ifndef wxCRT_StrchrW
310 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrchrW(const wchar_t *s
, wchar_t c
);
313 #ifndef wxCRT_StrcmpW
314 WXDLLIMPEXP_BASE
int wxCRT_StrcmpW(const wchar_t *s1
, const wchar_t *s2
);
317 #ifndef wxCRT_StrcollW
318 WXDLLIMPEXP_BASE
int wxCRT_StrcollW(const wchar_t *s1
, const wchar_t *s2
);
321 #ifndef wxCRT_StrcpyW
322 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrcpyW(wchar_t *dest
, const wchar_t *src
);
325 #ifndef wxCRT_StrcspnW
326 WXDLLIMPEXP_BASE
size_t wxCRT_StrcspnW(const wchar_t *s
, const wchar_t *reject
);
329 #ifndef wxCRT_StrncatW
330 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncatW(wchar_t *dest
, const wchar_t *src
, size_t n
);
333 #ifndef wxCRT_StrncpyW
334 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrncpyW(wchar_t *dest
, const wchar_t *src
, size_t n
);
337 #ifndef wxCRT_StrpbrkW
338 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrpbrkW(const wchar_t *s
, const wchar_t *accept
);
341 #ifndef wxCRT_StrrchrW
342 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrrchrW(const wchar_t *s
, wchar_t c
);
345 #ifndef wxCRT_StrspnW
346 WXDLLIMPEXP_BASE
size_t wxCRT_StrspnW(const wchar_t *s
, const wchar_t *accept
);
349 #ifndef wxCRT_StrstrW
350 WXDLLIMPEXP_BASE
const wchar_t *wxCRT_StrstrW(const wchar_t *haystack
, const wchar_t *needle
);
353 #ifndef wxCRT_StrtodW
354 WXDLLIMPEXP_BASE
double wxCRT_StrtodW(const wchar_t *nptr
, wchar_t **endptr
);
357 #ifndef wxCRT_StrtolW
358 WXDLLIMPEXP_BASE
long int wxCRT_StrtolW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
361 #ifndef wxCRT_StrtoulW
362 WXDLLIMPEXP_BASE
unsigned long int wxCRT_StrtoulW(const wchar_t *nptr
, wchar_t **endptr
, int base
);
365 #ifndef wxCRT_StrxfrmW
366 WXDLLIMPEXP_BASE
size_t wxCRT_StrxfrmW(wchar_t *dest
, const wchar_t *src
, size_t n
);
369 #ifndef wxCRT_StrdupA
370 WXDLLIMPEXP_BASE
char *wxCRT_StrdupA(const char *psz
);
373 #ifndef wxCRT_StrdupW
374 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrdupW(const wchar_t *pwz
);
377 #ifndef wxCRT_StricmpA
378 WXDLLIMPEXP_BASE
int wxCRT_StricmpA(const char *psz1
, const char *psz2
);
381 #ifndef wxCRT_StricmpW
382 WXDLLIMPEXP_BASE
int wxCRT_StricmpW(const wchar_t *psz1
, const wchar_t *psz2
);
385 #ifndef wxCRT_StrnicmpA
386 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpA(const char *psz1
, const char *psz2
, size_t len
);
389 #ifndef wxCRT_StrnicmpW
390 WXDLLIMPEXP_BASE
int wxCRT_StrnicmpW(const wchar_t *psz1
, const wchar_t *psz2
, size_t len
);
393 #ifndef wxCRT_StrtokA
394 WXDLLIMPEXP_BASE
char *wxCRT_StrtokA(char *psz
, const char *delim
, char **save_ptr
);
397 #ifndef wxCRT_StrtokW
398 WXDLLIMPEXP_BASE
wchar_t *wxCRT_StrtokW(wchar_t *psz
, const wchar_t *delim
, wchar_t **save_ptr
);
401 /* supply strtoll and strtoull, if needed */
403 #ifndef wxCRT_StrtollA
404 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollA(const char* nptr
,
407 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullA(const char* nptr
,
411 #ifndef wxCRT_StrtollW
412 WXDLLIMPEXP_BASE wxLongLong_t
wxCRT_StrtollW(const wchar_t* nptr
,
415 WXDLLIMPEXP_BASE wxULongLong_t
wxCRT_StrtoullW(const wchar_t* nptr
,
419 #endif // wxLongLong_t
422 /* -------------------------------------------------------------------------
424 ------------------------------------------------------------------------- */
426 #if defined(__UNIX__) || defined(__WXMAC__) || defined(__WXPALMOS__)
433 /* these functions are only needed in the form used for filenames (i.e. char*
434 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
435 #if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */
437 #define wxCRT_Fopen fopen
438 #define wxCRT_Freopen freopen
439 #define wxCRT_Remove remove
440 #define wxCRT_Rename rename
442 #else /* Unicode filenames */
443 /* special case: these functions are missing under Win9x with Unicows so we
444 have to implement them ourselves */
445 #if wxUSE_UNICODE_MSLU
446 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfopen(const wchar_t *name
, const wchar_t *mode
);
447 WXDLLIMPEXP_BASE
FILE* wxMSLU__wfreopen(const wchar_t *name
, const wchar_t *mode
, FILE *stream
);
448 WXDLLIMPEXP_BASE
int wxMSLU__wrename(const wchar_t *oldname
, const wchar_t *newname
);
449 WXDLLIMPEXP_BASE
int wxMSLU__wremove(const wchar_t *name
);
450 #define wxCRT_Fopen wxMSLU__wfopen
451 #define wxCRT_Freopen wxMSLU__wfreopen
452 #define wxCRT_Remove wxMSLU__wremove
453 #define wxCRT_Rename wxMSLU__wrename
455 /* WinCE CRT doesn't provide these functions so use our own */
457 WXDLLIMPEXP_BASE
int wxCRT_Rename(const wchar_t *src
,
459 WXDLLIMPEXP_BASE
int wxCRT_Remove(const wchar_t *path
);
461 #define wxCRT_Rename _wrename
462 #define wxCRT_Remove _wremove
464 #define wxCRT_Fopen _wfopen
465 #define wxCRT_Freopen _wfreopen
468 #endif /* wxMBFILES/!wxMBFILES */
470 #define wxCRT_PutsA puts
471 #define wxCRT_FputsA fputs
472 #define wxCRT_FgetsA fgets
473 #define wxCRT_FputcA fputc
474 #define wxCRT_FgetcA fgetc
475 #define wxCRT_UngetcA ungetc
477 #ifdef wxHAVE_TCHAR_SUPPORT
478 #define wxCRT_PutsW _putws
479 #define wxCRT_FputsW fputws
480 #define wxCRT_FputcW fputwc
483 #define wxCRT_FputsW fputws
486 #define wxCRT_PutsW putws
489 #define wxCRT_FputcW fputwc
491 #define wxCRT_FgetsW fgetws
494 WXDLLIMPEXP_BASE
int wxCRT_PutsW(const wchar_t *ws
);
498 WXDLLIMPEXP_BASE
int wxCRT_FputsW(const wchar_t *ch
, FILE *stream
);
502 WXDLLIMPEXP_BASE
int wxCRT_FputcW(wchar_t wc
, FILE *stream
);
506 NB: tmpnam() is unsafe and thus is not wrapped!
507 Use other wxWidgets facilities instead:
508 wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream
510 #define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead
512 /* FIXME-CE: provide our own perror() using ::GetLastError() */
515 #define wxCRT_PerrorA perror
516 #ifdef wxHAVE_TCHAR_SUPPORT
517 #define wxCRT_PerrorW _wperror
520 #endif /* !__WXWINCE__ */
522 /* -------------------------------------------------------------------------
524 ------------------------------------------------------------------------- */
526 /* there are no env vars at all under CE, so no _tgetenv neither */
528 /* can't define as inline function as this is a C file... */
529 #define wxCRT_GetenvA(name) (name, NULL)
530 #define wxCRT_GetenvW(name) (name, NULL)
532 #define wxCRT_GetenvA getenv
534 #define wxCRT_GetenvW _wgetenv
538 #ifndef wxCRT_GetenvW
539 WXDLLIMPEXP_BASE
wchar_t * wxCRT_GetenvW(const wchar_t *name
);
543 #define wxCRT_SystemA system
544 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
545 #if defined(_tsystem)
546 #define wxCRT_SystemW _wsystem
549 #define wxCRT_AtofA atof
550 #define wxCRT_AtoiA atoi
551 #define wxCRT_AtolA atol
553 #if defined(__MWERKS__)
555 #define wxCRT_AtofW watof
556 #define wxCRT_AtoiW watoi
557 #define wxCRT_AtolW watol
558 /* else: use ANSI versions */
560 #elif defined(wxHAVE_TCHAR_SUPPORT)
561 #define wxCRT_AtoiW _wtoi
562 #define wxCRT_AtolW _wtol
563 /* _wtof doesn't exist */
566 #define wxCRT_AtofW(s) wcstod(s, NULL)
568 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
569 /* wcstoi doesn't exist */
573 There are 2 unrelated problems with these functions under Mac:
574 a) Metrowerks MSL CRT implements them strictly in C99 sense and
575 doesn't support (very common) extension of allowing to call
576 mbstowcs(NULL, ...) which makes it pretty useless as you can't
577 know the size of the needed buffer
578 b) OS X <= 10.2 declares and even defined these functions but
579 doesn't really implement them -- they always return an error
581 So use our own replacements in both cases.
583 #if defined(__MWERKS__) && defined(__MSL__)
584 #define wxNEED_WX_MBSTOWCS
586 #if defined(__WXPALMOS__)
587 #define wxNEED_WX_MBSTOWCS
591 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
592 #define wxNEED_WX_MBSTOWCS
596 #ifdef wxNEED_WX_MBSTOWCS
597 /* even though they are defined and "implemented", they are bad and just
598 stubs so we need our own - we need these even in ANSI builds!! */
599 WXDLLIMPEXP_BASE
size_t wxMbstowcs(wchar_t *, const char *, size_t);
600 WXDLLIMPEXP_BASE
size_t wxWcstombs(char *, const wchar_t *, size_t);
602 #define wxMbstowcs mbstowcs
603 #define wxWcstombs wcstombs
608 /* -------------------------------------------------------------------------
610 ------------------------------------------------------------------------- */
612 #define wxCRT_StrftimeA strftime
614 /* FIXME-UTF8: when is this available? */
615 #define wxCRT_StrftimeW wcsftime
616 #endif /* ! __WXPALMOS__ */
618 #ifndef wxCRT_StrftimeW
619 WXDLLIMPEXP_BASE
size_t wxCRT_StrftimeW(wchar_t *s
, size_t max
,
621 const struct tm
*tm
);
626 /* -------------------------------------------------------------------------
628 ------------------------------------------------------------------------- */
631 #define WXWCHAR_T_CAST(c) (wint_t)(c)
633 #define WXWCHAR_T_CAST(c) c
636 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
637 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
638 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
639 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
640 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
641 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
642 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
643 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
644 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
645 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
646 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
649 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
650 /* /usr/include/wctype.h incorrectly declares translations */
651 /* tables which provokes tons of compile-time warnings -- try */
652 /* to correct this */
653 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
654 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
655 #else /* !glibc 2.0 */
656 #define wxCRT_TolowerW towlower
657 #define wxCRT_ToupperW towupper
659 #else /* !__GLIBC__ */
660 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
661 with signed chars < 0, so "fix" it here. */
662 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
663 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
664 #endif /* __GLIBC__/!__GLIBC__ */
670 /* -------------------------------------------------------------------------
671 wx wrappers for CRT functions in both char* and wchar_t* versions
672 ------------------------------------------------------------------------- */
676 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
677 * for buffer.h and stringimpl.h (both of which must be included before
678 * string.h, which is required by wxcrt.h) to have them here: */
680 /* safe version of strlen() (returns 0 if passed NULL pointer) */
681 inline size_t wxStrlen(const char *s
) { return s
? wxCRT_StrlenA(s
) : 0; }
682 inline size_t wxStrlen(const wchar_t *s
) { return s
? wxCRT_StrlenW(s
) : 0; }
683 #ifndef wxWCHAR_T_IS_WXCHAR16
684 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar16
*s
);
686 #ifndef wxWCHAR_T_IS_WXCHAR32
687 WXDLLIMPEXP_BASE
size_t wxStrlen(const wxChar32
*s
);
689 #define wxWcslen wxCRT_StrlenW
691 #define wxStrdupA wxCRT_StrdupA
692 #define wxStrdupW wxCRT_StrdupW
693 inline char* wxStrdup(const char *s
) { return wxCRT_StrdupA(s
); }
694 inline wchar_t* wxStrdup(const wchar_t *s
) { return wxCRT_StrdupW(s
); }
695 #ifndef wxWCHAR_T_IS_WXCHAR16
696 WXDLLIMPEXP_BASE wxChar16
* wxStrdup(const wxChar16
* s
);
698 #ifndef wxWCHAR_T_IS_WXCHAR32
699 WXDLLIMPEXP_BASE wxChar32
* wxStrdup(const wxChar32
* s
);
702 #endif /* __cplusplus */
704 #endif /* _WX_WXCRTBASE_H_ */