3
* Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4
* Author: Joel Farley, Ove Kaaven
5
* Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
7
* RCS-ID: $Id: wxchar.h 66970 2011-02-19 13:54:14Z VZ $
8
* Copyright: (c) 1998-2006 wxWidgets dev team
9
* Licence: wxWindows licence
12
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
17
/* defs.h indirectly includes this file, so don't include it here */
18
#include "wx/platform.h"
19
#include "wx/dlimpexp.h"
21
#include <stdio.h> /* we use FILE below */
23
#if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
24
char *strtok_r(char *, const char *, char **);
27
/* check whether we have wchar_t and which size it is if we do */
28
#if !defined(wxUSE_WCHAR_T)
30
#if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
31
#define wxUSE_WCHAR_T 1
33
#define wxUSE_WCHAR_T 0
35
#elif defined(__GNUWIN32__) && !defined(__MINGW32__)
36
#define wxUSE_WCHAR_T 0
37
#elif defined(__WATCOMC__)
38
#define wxUSE_WCHAR_T 0
39
#elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
40
#define wxUSE_WCHAR_T 0
42
/* add additional compiler checks if this fails */
43
#define wxUSE_WCHAR_T 1
45
#endif /* !defined(wxUSE_WCHAR_T) */
47
/* Unicode support requires wchar_t */
48
#if wxUSE_UNICODE && !wxUSE_WCHAR_T
49
#error "wchar_t must be available in Unicode build"
53
Standard headers we need here.
55
NB: don't include any wxWidgets headers here because almost all of them include
59
/* Required for wxPrintf() etc */
62
/* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
63
/* and VC++ for Windows CE don't provide it */
64
#if defined(__VISUALC__) && __VISUALC__ >= 1400
65
#define wxStrdupA _strdup
66
#elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
67
/* use #define, not inline wrapper, as it is tested with #ifndef below */
68
#define wxStrdupA strdup
72
non Unix compilers which do have wchar.h (but not tchar.h which is included
73
below and which includes wchar.h anyhow).
75
Actually MinGW has tchar.h, but it does not include wchar.h
77
#if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
82
#if defined(__MWERKS__) && !defined(__MACH__)
90
/* the current (as of Nov 2002) version of cygwin has a bug in its */
91
/* wchar.h -- there is no extern "C" around the declarations in it and */
92
/* this results in linking errors later; also, at least on some */
93
/* Cygwin versions, wchar.h requires sys/types.h */
95
#include <sys/types.h>
103
#if defined(__CYGWIN__) && defined(__cplusplus)
105
#endif /* Cygwin and C++ */
107
#elif defined(HAVE_WCSTR_H)
108
/* old compilers have relevant declarations here */
110
#elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
111
/* include stdlib.h for wchar_t */
113
#endif /* HAVE_WCHAR_H */
118
#endif /* wxUSE_WCHAR_T */
120
/* ---------------------------------------------------------------------------- */
121
/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
122
/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
123
/* the function mapping _tfoo() -> foo() or wfoo() */
124
/* ---------------------------------------------------------------------------- */
126
/* VC++ and BC++ starting with 5.2 have TCHAR support */
128
#define wxHAVE_TCHAR_SUPPORT
129
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
130
#define wxHAVE_TCHAR_SUPPORT
133
#elif defined(__WATCOMC__)
134
#define wxHAVE_TCHAR_SUPPORT
135
#elif defined(__DMC__)
136
#define wxHAVE_TCHAR_SUPPORT
137
#elif defined(__WXPALMOS__)
139
#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
140
#define wxHAVE_TCHAR_SUPPORT
144
#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
145
/* VZ: the old VisualAge definitions were completely wrong and had no */
146
/* chance at all to work in Unicode build anyhow so let's pretend that */
147
/* VisualAge does _not_ support TCHAR for the moment (as indicated by */
148
/* "0 &&" above) until someone really has time to delve into Unicode */
149
/* issues under OS/2 */
151
/* VisualAge 4.0+ supports TCHAR */
152
#define wxHAVE_TCHAR_SUPPORT
153
#endif /* compilers with (good) TCHAR support */
155
#if defined(__MWERKS__)
156
/* Metrowerks only has wide char support for OS X >= 10.3 */
157
#if !defined(__DARWIN__) || \
158
(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
159
#define wxHAVE_MWERKS_UNICODE
162
#ifdef wxHAVE_MWERKS_UNICODE
163
#define HAVE_WPRINTF 1
164
#define HAVE_WCSRTOMBS 1
165
#define HAVE_VSWPRINTF 1
167
#endif /* __MWERKS__ */
169
#ifdef wxHAVE_TCHAR_SUPPORT
170
/* get TCHAR definition if we've got it */
173
/* we surely do have wchar_t if we have TCHAR */
174
#ifndef wxUSE_WCHAR_T
175
#define wxUSE_WCHAR_T 1
176
#endif /* !defined(wxUSE_WCHAR_T) */
178
/* and we also do have wcslen() */
182
#endif /* wxHAVE_TCHAR_SUPPORT */
184
/* ---------------------------------------------------------------------------- */
185
/* define wxChar type */
186
/* ---------------------------------------------------------------------------- */
188
/* TODO: define wxCharInt to be equal to either int or wint_t? */
192
typedef signed char wxSChar;
193
typedef unsigned char wxUChar;
195
/* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
196
/* signed/unsigned version of it which (a) makes sense to me (unlike */
197
/* char wchar_t is always unsigned) and (b) was how the previous */
198
/* definitions worked so keep it like this */
200
/* Sun's SunPro compiler supports the wchar_t type and wide character */
201
/* functions, but does not define __WCHAR_TYPE__. Define it here to */
202
/* allow unicode enabled builds. */
203
#if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
204
#define __WCHAR_TYPE__ wxchar_t
207
/* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
209
#if !defined(__WCHAR_TYPE__) || \
210
(!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
212
typedef wchar_t wxChar;
213
typedef wchar_t wxSChar;
214
typedef wchar_t wxUChar;
215
#else /* __WCHAR_TYPE__ and gcc < 2.96 */
216
/* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. However, */
217
/* this doesn't work with new GCC 3.x compilers because wchar_t is */
218
/* C++'s builtin type in the new standard. OTOH, old compilers (GCC */
219
/* 2.x) won't accept new definition of wx{S,U}Char, therefore we */
220
/* have to define wxChar conditionally depending on detected */
221
/* compiler & compiler version. */
222
/* with old definition of wxChar. */
223
typedef __WCHAR_TYPE__ wxChar;
224
typedef __WCHAR_TYPE__ wxSChar;
225
typedef __WCHAR_TYPE__ wxUChar;
226
#endif /* __WCHAR_TYPE__ */
227
#endif /* ASCII/Unicode */
229
/* ---------------------------------------------------------------------------- */
230
/* define wxT() and related macros */
231
/* ---------------------------------------------------------------------------- */
234
/* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
235
#define wxT(x) wxCONCAT_HELPER(L, x)
238
#endif /* Unicode/!Unicode */
241
This macro is defined for forward compatibility with wxWidgets 3. It should
242
be used in the places where wxWidgets 2 API requires wxT() (in Unicode
243
build) but wxWidgets 3 doesn't accept it, e.g. wxCmdLineEntryDesc struct
244
elements initializers.
246
#define wxT_2(x) wxT(x)
249
We define _T() as a synonym of wxT() for backwards compatibility and also
250
for the benefit of Windows programmers used to it. But this identifier is a
251
reserved one and this does create problems in practice, notably with Sun CC
252
which uses it in the recent versions of its standard headers. So avoid
253
defining it for this compiler at all, unless it was explicitly requested by
254
predefining wxNEEDS__T macro before including this header or if we're
255
building wx itself which does need and compiles fine thanks to the special
256
workarounds for Sun CC in wx/{before,after}std.h.
259
#if defined(WXBUILDING) || !(defined (__SUNPRO_C) || defined(__SUNPRO_CC))
265
/* BSDs define _T() to be something different in ctype.h, override it */
266
#if defined(__FreeBSD__) || defined(__DARWIN__)
272
#endif /* wxNEEDS__T */
274
/* this macro exists only for forward compatibility with wx 3.0 */
275
#define wxS(x) wxT(x)
277
/* a helper macro allowing to make another macro Unicode-friendly, see below */
278
#define wxAPPLY_T(x) wxT(x)
280
/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
282
#define __TFILE__ wxAPPLY_T(__FILE__)
286
#define __TDATE__ wxAPPLY_T(__DATE__)
290
#define __TTIME__ wxAPPLY_T(__TIME__)
294
define wxFoo() function for each standard foo() function whose signature
295
(exceptionally including the return type) includes any mention of char:
296
wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
297
the same signature but with char replaced by wxChar which allows us to use
298
it in Unicode build as well
301
#ifdef wxHAVE_TCHAR_SUPPORT
304
#if defined(__WATCOMC__) && defined(UNICODE)
305
#define WXWCHAR_T_CAST(c) (wint_t)(c)
307
#define WXWCHAR_T_CAST(c) c
310
/* ctype.h functions */
311
#define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
312
#define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
313
#define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
314
#define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
315
#define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
316
#define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
317
#define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
318
#define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
319
#define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
320
#define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
321
#define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
324
There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
325
signed chars < 0, so "fix" it here.
327
#define wxTolower(c) _totlower((wxUChar)(c))
328
#define wxToupper(c) _totupper((wxUChar)(c))
330
/* locale.h functons */
331
#define wxSetlocale _tsetlocale
333
/* string.h functions */
334
#define wxStrcat _tcscat
335
#define wxStrchr _tcschr
336
#define wxStrcmp _tcscmp
337
#define wxStrcoll _tcscoll
338
#define wxStrcpy _tcscpy
339
#define wxStrcspn _tcscspn
340
#define wxStrdupW _wcsdup /* notice the 'W'! */
341
#define wxStrftime _tcsftime
342
#define wxStricmp _tcsicmp
343
#define wxStrnicmp _tcsnicmp
344
#define wxStrlen_ _tcslen /* used in wxStrlen inline function */
345
#define wxStrncat _tcsncat
346
#define wxStrncmp _tcsncmp
347
#define wxStrncpy _tcsncpy
348
#define wxStrpbrk _tcspbrk
349
#define wxStrrchr _tcsrchr
350
#define wxStrspn _tcsspn
351
#define wxStrstr _tcsstr
352
#define wxStrtod _tcstod
353
#define wxStrtol _tcstol
354
#define wxStrtoul _tcstoul
356
#if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
357
#define wxStrtoll _tcstoi64
358
#define wxStrtoull _tcstoui64
361
#define wxStrxfrm _tcsxfrm
363
/* stdio.h functions */
364
#define wxFgetc _fgettc
365
#define wxFgetchar _fgettchar
366
#define wxFgets _fgetts
367
#if wxUSE_UNICODE_MSLU
368
WXDLLIMPEXP_BASE FILE * wxMSLU__tfopen(const wxChar *name, const wxChar *mode);
370
#define wxFopen wxMSLU__tfopen
372
#define wxFopen _tfopen
374
#define wxFputc _fputtc
375
#define wxFputchar _fputtchar
376
#define wxFprintf _ftprintf
377
#define wxFputs _fputts
378
#define wxFreopen _tfreopen
379
#define wxFscanf _ftscanf
380
#define wxGetc _gettc
381
#define wxGetchar _gettchar
382
#define wxGets _getts
383
#define wxPerror _tperror
384
#define wxPrintf _tprintf
385
#define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
386
#define wxPutchar _puttchar
387
#define wxPuts _putts
388
#define wxScanf _tscanf
391
/* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
392
int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
394
/* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
395
#define wxSprintf sprintf
397
#elif defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 )
399
/* MinGW with STLPort 5.1 adds count to swprintf (C99) so prototype conversion see wxchar.cpp */
400
int wxSprintf (wchar_t*, const wchar_t*, ...);
402
/* MinGW with STLPort 5.1 has clashing defines for _stprintf so use sprintf */
403
#define wxSprintf sprintf
406
#define wxSprintf _stprintf
409
#define wxSscanf _stscanf
410
#define wxTmpnam _ttmpnam
411
#define wxUngetc _tungetc
412
#define wxVfprintf _vftprintf
413
#define wxVprintf _vtprintf
414
#define wxVsscanf _vstscanf
415
#define wxVsprintf _vstprintf
417
/* special case: these functions are missing under Win9x with Unicows so we */
418
/* have to implement them ourselves */
419
#if wxUSE_UNICODE_MSLU
420
WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname);
421
WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name);
423
#define wxRemove wxMSLU__tremove
424
#define wxRename wxMSLU__trename
427
/* carefully: wxRemove() must return 0 on success while DeleteFile()
428
returns 0 on error, so don't just define one as the other */
429
int wxRemove(const wxChar *path);
431
#define wxRemove _tremove
432
#define wxRename _trename
436
/* stdlib.h functions */
439
/* #define wxAtof _tttof -- notice that there is no such thing (why?) */
440
/* there are no env vars at all under CE, so no _tgetenv neither */
442
/* can't define as inline function as this is a C file... */
443
#define wxGetenv(name) ((wxChar *)NULL)
445
#define wxGetenv _tgetenv
447
#define wxSystem _tsystem
449
/* time.h functions */
450
#define wxAsctime _tasctime
451
#define wxCtime _tctime
453
#define wxMbstowcs mbstowcs
454
#define wxWcstombs wcstombs
455
#else /* !TCHAR-aware compilers */
457
There are 2 unrelated problems with these functions under Mac:
458
a) Metrowerks MSL CRT implements them strictly in C99 sense and
459
doesn't support (very common) extension of allowing to call
460
mbstowcs(NULL, ...) which makes it pretty useless as you can't
461
know the size of the needed buffer
462
b) OS X <= 10.2 declares and even defined these functions but
463
doesn't really implement them -- they always return an error
465
So use our own replacements in both cases.
467
#if defined(__MWERKS__) && defined(__MSL__)
468
#define wxNEED_WX_MBSTOWCS
472
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
473
#define wxNEED_WX_MBSTOWCS
477
#ifdef wxNEED_WX_MBSTOWCS
478
/* even though they are defined and "implemented", they are bad and just
479
stubs so we need our own - we need these even in ANSI builds!! */
480
WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t);
481
WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t);
483
#define wxMbstowcs mbstowcs
484
#define wxWcstombs wcstombs
488
The system C library on Mac OS X 10.2 and below does not support
489
unicode: in other words all wide-character functions such as towupper et
490
al. do simply not exist so we need to provide our own in that context,
491
except for the wchar_t definition/typedef itself.
493
We need to do this for both project builder and CodeWarrior as
494
the latter uses the system C library in Mach builds for wide character
495
support, which as mentioned does not exist on 10.2 and below.
497
#if wxUSE_UNICODE && \
498
defined(__DARWIN__) && \
499
( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
500
/* we need everything! */
501
#define wxNEED_WX_STRING_H
502
#define wxNEED_WX_CTYPE_H
504
#define wxFgetchar(c) wxFgetc(c, stdin)
505
#define wxFputc wxPutc
506
#define wxFputchar(c) wxPutc(c, stdout)
507
#define wxGetc wxFgetc
508
#define wxGetchar(c) wxFgetc(c, stdin)
515
#define wxNEED_UNGETC
521
int wxFputs(const wxChar *ch, FILE *stream);
522
int wxPuts(const wxChar *ws);
523
int wxPutc(wxChar ch, FILE *stream);
528
WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
533
#define wxPutchar(wch) wxPutc(wch, stdout)
535
#define wxNEED_PRINTF_CONVERSION
536
#define wxNEED_WX_STDIO_H
537
#define wxNEED_WX_STDLIB_H
538
#define wxNEED_WX_TIME_H
543
/* this is probably glibc-specific */
544
#if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
545
/* ctype.h functions (wctype.h) */
546
#define wxIsalnum iswalnum
547
#define wxIsalpha iswalpha
548
#define wxIscntrl iswcntrl
549
#define wxIsdigit iswdigit
550
#define wxIsgraph iswgraph
551
#define wxIslower iswlower
552
#define wxIsprint iswprint
553
#define wxIspunct iswpunct
554
#define wxIsspace iswspace
555
#define wxIsupper iswupper
556
#define wxIsxdigit iswxdigit
558
#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
559
/* /usr/include/wctype.h incorrectly declares translations */
560
/* tables which provokes tons of compile-time warnings -- try */
561
/* to correct this */
562
#define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
563
#define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
564
#else /* !glibc 2.0 */
565
#define wxTolower towlower
566
#define wxToupper towupper
567
#endif /* gcc/!gcc */
569
/* string.h functions (wchar.h) */
570
#define wxStrcat wcscat
571
#define wxStrchr wcschr
572
#define wxStrcmp wcscmp
573
#define wxStrcoll wcscoll
574
#define wxStrcpy wcscpy
575
#define wxStrcspn wcscspn
576
#define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
577
#define wxStrncat wcsncat
578
#define wxStrncmp wcsncmp
579
#define wxStrncpy wcsncpy
580
#define wxStrpbrk wcspbrk
581
#define wxStrrchr wcsrchr
582
#define wxStrspn wcsspn
583
#define wxStrstr wcsstr
584
#define wxStrtod wcstod
585
#define wxStrtol wcstol
586
#define wxStrtoul wcstoul
588
/* assume that we have wcstoull(), which is also C99, too */
589
#define wxStrtoll wcstoll
590
#define wxStrtoull wcstoull
591
#endif /* HAVE_WCSTOULL */
592
#define wxStrxfrm wcsxfrm
594
#define wxFgetc fgetwc
595
#define wxFgetchar fgetwchar
596
#define wxFgets fgetws
597
#define wxFputc fputwc
598
#define wxFputchar fputwchar
600
#define wxGetchar getwchar
602
#define wxUngetc ungetwc
605
#define wxFputs fputws
609
int wxFputs(const wxChar *ch, FILE *stream);
617
int wxPutc(wxChar ch, FILE *stream);
621
#define wxPutchar wputchar
623
#define wxPutchar(wch) wxPutc(wch, stdout)
630
int wxPuts(const wxChar *ws);
633
/* we need %s to %ls conversion for printf and scanf etc */
634
#define wxNEED_PRINTF_CONVERSION
636
/* glibc doesn't have wide char equivalents of the other stuff so */
637
/* use our own versions */
638
#define wxNEED_WX_STDIO_H
639
#define wxNEED_WX_STDLIB_H
640
#define wxNEED_WX_TIME_H
641
#elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
642
/* ctype.h functions (wctype.h) */
643
#define wxIsalnum iswalnum
644
#define wxIsalpha iswalpha
645
#define wxIscntrl iswcntrl
646
#define wxIsdigit iswdigit
647
#define wxIsgraph iswgraph
648
#define wxIslower iswlower
649
#define wxIsprint iswprint
650
#define wxIspunct iswpunct
651
#define wxIsspace iswspace
652
#define wxIsupper iswupper
653
#define wxIsxdigit iswxdigit
654
#define wxTolower towlower
655
#define wxToupper towupper
657
/* string.h functions (wchar.h) */
658
#define wxStrcat wcscat
659
#define wxStrchr wcschr
660
#define wxStrcmp wcscmp
661
#define wxStrcoll wcscoll
662
#define wxStrcpy wcscpy
663
#define wxStrcspn wcscspn
664
#define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
665
#define wxStrncat wcsncat
666
#define wxStrncmp wcsncmp
667
#define wxStrncpy wcsncpy
668
#define wxStrpbrk wcspbrk
669
#define wxStrrchr wcsrchr
670
#define wxStrspn wcsspn
671
#define wxStrstr wcsstr
672
#define wxStrtod wcstod
673
#define wxStrtol wcstol
674
#define wxStrtoul wcstoul
675
#define wxStrxfrm wcsxfrm
677
#define wxFgetc fgetwc
678
#define wxFgetchar fgetwchar
679
#define wxFgets fgetws
680
#define wxFputc fputwc
681
#define wxFputchar fputwchar
683
#define wxGetchar getwchar
685
#define wxUngetc ungetwc
687
#define wxNEED_PRINTF_CONVERSION
690
#define wxPutchar putwchar
691
#define wxFputs fputws
693
/* stdio.h functions */
695
#define wxNEED_WX_STDIO_H
697
/* stdlib.h functions */
699
#define wxNEED_WX_STDLIB_H
704
#define wxGetenv(a) ((wxChar*)NULL)
705
#define wxSystem(a) ((int)NULL)
707
/* time.h functions */
708
#define wxAsctime wasciitime
709
#define wxCtime wctime
710
/* #define wxStrftime wcsftime */
712
#define wxNEED_WX_TIME_H
713
#else /* !metrowerks for apple */
714
#error "Please define wide character functions for your environment"
720
/* ctype.h functions */
721
#define wxIsalnum isalnum
722
#define wxIsalpha isalpha
723
#define wxIscntrl iscntrl
724
#define wxIsdigit isdigit
725
#define wxIsgraph isgraph
726
#define wxIslower islower
727
#define wxIsprint isprint
728
#define wxIspunct ispunct
729
#define wxIsspace isspace
730
#define wxIsupper isupper
731
#define wxIsxdigit isxdigit
732
#define wxTolower tolower
733
#define wxToupper toupper
735
/* locale.h functons */
736
#define wxSetlocale setlocale
738
/* string.h functions */
739
#define wxStrcat strcat
740
#define wxStrchr strchr
741
#define wxStrcmp strcmp
742
#define wxStrcoll strcoll
743
#define wxStrcpy strcpy
744
#define wxStrcspn strcspn
746
/* wxStricmp and wxStrnicmp are defined below */
747
#define wxStrlen_ strlen /* used in wxStrlen inline function */
748
#define wxStrncat strncat
749
#define wxStrncmp strncmp
750
#define wxStrncpy strncpy
751
#define wxStrpbrk strpbrk
752
#define wxStrrchr strrchr
753
#define wxStrspn strspn
754
#define wxStrstr strstr
755
#define wxStrtod strtod
757
#define wxStrtok(str, sep, last) strtok_r(str, sep, last)
759
#define wxStrtol strtol
760
#define wxStrtoul strtoul
762
/* assume that we have wcstoull(), which is also C99, too */
763
#define wxStrtoll strtoll
764
#define wxStrtoull strtoull
765
#endif /* HAVE_WCSTOULL */
766
#define wxStrxfrm strxfrm
768
/* stdio.h functions */
769
#define wxFopen fopen
770
#define wxFreopen freopen
771
#define wxRemove remove
772
#define wxRename rename
774
#define wxPerror perror
775
#define wxTmpnam tmpnam
777
#define wxFgetc fgetc
778
#define wxFgetchar fgetchar
779
#define wxFgets fgets
780
#define wxFputc fputc
781
#define wxFputs fputs
782
#define wxFputchar fputchar
783
#define wxFprintf fprintf
784
#define wxFscanf fscanf
786
#define wxGetchar getchar
788
#define wxPrintf printf
790
#define wxPutchar putchar
792
#define wxScanf scanf
793
#define wxSprintf sprintf
794
#define wxSscanf sscanf
795
#define wxUngetc ungetc
796
#define wxVfprintf vfprintf
797
#define wxVprintf vprintf
798
#define wxVsscanf vsscanf
799
#define wxVsprintf vsprintf
801
/* stdlib.h functions */
805
#define wxGetenv getenv
806
#define wxSystem system
808
/* time.h functions */
809
#define wxAsctime asctime
810
#define wxCtime ctime
811
#define wxStrftime strftime
812
#endif /* Unicode/ASCII */
813
#endif /* TCHAR-aware compilers/the others */
816
#define wxHAS_STRTOLL
820
various special cases
823
/* define wxStricmp and wxStrnicmp for various compilers */
825
/* note that in Unicode mode we definitely are going to need our own version */
826
#if !defined(wxStricmp) && !wxUSE_UNICODE
827
#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
828
defined(__SALFORDC__) || defined(__VISAGECPP__) || \
829
defined(__EMX__) || defined(__DJGPP__)
830
#define wxStricmp stricmp
831
#define wxStrnicmp strnicmp
832
#elif defined(__WXPALMOS__)
833
/* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
834
* quick hack should do until one can be written.
836
#define wxStricmp StrCaselessCompare
837
#define wxStrnicmp strnicmp
838
#elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
839
(defined(__MWERKS__) && defined(__INTEL__))
840
#define wxStricmp _stricmp
841
#define wxStrnicmp _strnicmp
842
#elif defined(__UNIX__) || defined(__GNUWIN32__)
843
#define wxStricmp strcasecmp
844
#define wxStrnicmp strncasecmp
845
/* #else -- use wxWidgets implementation */
847
#endif /* !defined(wxStricmp) */
849
/* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
850
/* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
851
/* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
854
#define wxWcslen wcslen
856
WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s);
858
#endif /* wxUSE_WCHAR_T */
861
/* checks whether the passed in pointer is NULL and if the string is empty */
862
inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
864
/* safe version of strlen() (returns 0 if passed NULL pointer) */
865
inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; }
869
each of strdup() and wcsdup() may or may not be available but we need both
870
of them anyhow for wx/buffer.h so we define the missing one(s) in
871
wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
872
defined -- if this is somehow not the case in some situations, please
873
correct that and not the lines here
876
#define wxStrdup wxStrdupW
878
#define wxStrdup wxStrdupA
882
WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
885
/* printf() family saga */
888
For some systems [v]snprintf() exists in the system libraries but not in the
889
headers, so we need to declare it ourselves to be able to use it.
891
#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
897
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
898
#endif /* !HAVE_VSNPRINTF_DECL */
900
#if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL)
906
WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...);
907
#endif /* !HAVE_SNPRINTF_DECL */
909
/* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the
910
* same isn't done for snprintf below, the builtin wxSnprintf_ is used
911
* instead since it's already a simple wrapper */
912
#if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL
913
inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap)
915
return vsnprintf(str, size, (char*)format, ap);
920
MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility
921
presumably) and normally _vsnwprintf() is used instead (but as
922
STLPort 5.1 defines standard vswprintf(), don't do this for it)
924
#if defined(HAVE_VSWPRINTF) && defined(__MINGW32__) && !( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 )
925
#undef HAVE_VSWPRINTF
928
#if wxUSE_PRINTF_POS_PARAMS
930
The systems where vsnprintf() supports positional parameters should
931
define the HAVE_UNIX98_PRINTF symbol.
933
On systems which don't (e.g. Windows) we are forced to use
934
our wxVsnprintf() implementation.
936
#if defined(HAVE_UNIX98_PRINTF)
938
#ifdef HAVE_VSWPRINTF
939
#define wxVsnprintf_ vswprintf
942
#ifdef HAVE_BROKEN_VSNPRINTF_DECL
943
#define wxVsnprintf_ wx_fixed_vsnprintf
945
#define wxVsnprintf_ vsnprintf
948
#else /* !HAVE_UNIX98_PRINTF */
950
The only compiler with positional parameters support under Windows
951
is VC++ 8.0 which provides a new xxprintf_p() functions family.
952
The 2003 PSDK includes a slightly earlier version of VC8 than the
953
main release and does not have the printf_p functions.
955
#if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__
957
#define wxVsnprintf_ _vswprintf_p
959
#define wxVsnprintf_ _vsprintf_p
962
#endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */
963
#else /* !wxUSE_PRINTF_POS_PARAMS */
965
We always want to define safe snprintf() function to be used instead of
966
sprintf(). Some compilers already have it (or rather vsnprintf() which
967
we really need...), otherwise we implement it using our own printf()
970
We define function with a trailing underscore here because the real one
971
is a wrapper around it as explained below
974
/* first deal with TCHAR-aware compilers which have _vsntprintf */
976
#if defined(__VISUALC__) || \
977
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
978
#define wxVsnprintf_ _vsntprintf
979
#define wxSnprintf_ _sntprintf
983
/* if this didn't work, define it separately for Unicode and ANSI builds */
986
#if defined(HAVE__VSNWPRINTF)
987
#define wxVsnprintf_ _vsnwprintf
988
#elif defined(HAVE_VSWPRINTF)
989
#define wxVsnprintf_ vswprintf
990
#elif defined(__WATCOMC__)
991
#define wxVsnprintf_ _vsnwprintf
992
#define wxSnprintf_ _snwprintf
996
All versions of CodeWarrior supported by wxWidgets apparently
997
have both snprintf() and vsnprintf()
999
#if defined(HAVE_SNPRINTF) \
1000
|| defined(__MWERKS__) || defined(__WATCOMC__)
1001
#ifndef HAVE_BROKEN_SNPRINTF_DECL
1002
#define wxSnprintf_ snprintf
1005
#if defined(HAVE_VSNPRINTF) \
1006
|| defined(__MWERKS__) || defined(__WATCOMC__)
1007
#ifdef HAVE_BROKEN_VSNPRINTF_DECL
1008
#define wxVsnprintf_ wx_fixed_vsnprintf
1010
#define wxVsnprintf_ vsnprintf
1013
#endif /* Unicode/ASCII */
1014
#endif /* wxVsnprintf_ */
1015
#endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */
1018
/* no snprintf(), cook our own */
1019
WXDLLIMPEXP_BASE int
1020
wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
1022
#ifndef wxVsnprintf_
1023
/* no (suitable) vsnprintf(), cook our own */
1024
WXDLLIMPEXP_BASE int
1025
wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format, va_list argptr);
1027
#define wxUSE_WXVSNPRINTF 1
1029
#define wxUSE_WXVSNPRINTF 0
1033
In Unicode mode we need to have all standard functions such as wprintf() and
1034
so on but not all systems have them so use our own implementations in this
1037
#if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
1038
#define wxNEED_WPRINTF
1042
More Unicode complications: although both ANSI C and C++ define a number of
1043
wide character functions such as wprintf(), not all environments have them.
1044
Worse, those which do have different behaviours: under Windows, %s format
1045
specifier changes its meaning in Unicode build and expects a Unicode string
1046
while under Unix/POSIX it still means an ASCII string even for wprintf() and
1047
%ls has to be used for wide strings.
1049
We choose to always emulate Windows behaviour as more useful for us so even
1050
if we have wprintf() we still must wrap it in a non trivial wxPrintf().
1054
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
1056
we need to implement all wide character printf and scanf functions
1057
either because we don't have them at all or because they don't have the
1060
int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1061
int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1062
int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1063
int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
1064
int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1065
int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1066
int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1067
int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
1068
int wxVprintf( const wxChar *format, va_list ap );
1069
int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
1070
#endif /* wxNEED_PRINTF_CONVERSION */
1072
/* these 2 can be simply mapped to the versions with underscore at the end */
1073
/* if we don't have to do the conversion */
1075
However, if we don't have any vswprintf() at all we don't need to redefine
1076
anything as our own wxVsnprintf_() already behaves as needed.
1078
#if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
1079
int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
1080
int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
1082
#define wxSnprintf wxSnprintf_
1083
#define wxVsnprintf wxVsnprintf_
1087
various functions which might not be available in libc and for which we
1088
provide our own replacements in wxchar.cpp
1091
/* ctype.h functions */
1093
/* RN: Used only under OSX <= 10.2 currently */
1094
#ifdef wxNEED_WX_CTYPE_H
1095
WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
1096
WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
1097
WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch);
1098
WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
1099
WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
1100
WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
1101
WXDLLIMPEXP_BASE int wxIsprint(wxChar ch);
1102
WXDLLIMPEXP_BASE int wxIspunct(wxChar ch);
1103
WXDLLIMPEXP_BASE int wxIsspace(wxChar ch);
1104
WXDLLIMPEXP_BASE int wxIsupper(wxChar ch);
1105
WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
1106
WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
1107
WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
1108
#endif /* wxNEED_WX_CTYPE_H */
1110
/* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
1111
/* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
1112
#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
1114
#define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
1118
a few compilers don't have the (non standard but common) isascii function,
1119
define it ourselves for them
1122
#if defined(__MWERKS__)
1123
#define wxNEED_ISASCII
1124
#elif defined(_WIN32_WCE)
1125
#if _WIN32_WCE <= 211
1126
#define wxNEED_ISASCII
1129
#endif /* isascii */
1131
#ifdef wxNEED_ISASCII
1132
inline int isascii(int c) { return (unsigned)c < 0x80; }
1136
#if _WIN32_WCE <= 211
1137
#define isspace(c) ((c) == wxT(' ') || (c) == wxT('\t'))
1139
#endif /* _WIN32_WCE */
1142
we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
1143
initial versions of this header -- now it is too late to remove it so
1144
although we fixed the function/macro name above, still provide the
1145
backwards-compatible synonym.
1147
#define wxIsctrl wxIscntrl
1149
/* string.h functions */
1151
#if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
1152
#define wxNEED_STRDUP
1153
#elif defined(__WXWINCE__)
1154
#if _WIN32_WCE <= 211
1155
#define wxNEED_STRDUP
1160
#ifdef wxNEED_STRDUP
1161
WXDLLIMPEXP_BASE char *strdup(const char* s);
1164
/* RN: Used only under OSX <= 10.2 currently
1165
The __cplusplus ifdefs are messy, but they are required to build
1166
the regex library, since c does not support function overloading
1168
#ifdef wxNEED_WX_STRING_H
1172
WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
1173
WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
1174
WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
1175
WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
1176
WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
1177
WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
1178
WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
1179
WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
1180
WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
1181
WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
1182
WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
1183
WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
1184
WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
1189
/* These functions use C++, so we can't c extern them */
1190
WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
1191
WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
1192
WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
1193
WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
1195
/* inlined versions */
1197
inline wxChar * wxStrchr(wxChar *s, wxChar c)
1198
{ return (wxChar *)wxStrchr((const wxChar *)s, c); }
1199
inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
1200
{ return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
1201
inline wxChar * wxStrrchr(wxChar *s, wxChar c)
1202
{ return (wxChar *)wxStrrchr((const wxChar *)s, c); }
1203
inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
1204
{ return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
1207
#endif /* wxNEED_WX_STRING_H */
1210
WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz);
1214
WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz);
1218
WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2);
1222
WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len);
1226
WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
1231
class WXDLLIMPEXP_BASE wxWCharBuffer;
1232
WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale);
1236
/* stdio.h functions */
1237
#ifdef wxNEED_WX_STDIO_H
1239
WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
1240
WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
1241
WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
1242
WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
1244
/* *printf() family is handled separately */
1245
#endif /* wxNEED_WX_STDIO_H */
1248
/* stdlib.h functions */
1250
WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz);
1254
mingw32 doesn't provide _tsystem() even though it does provide all the other
1255
stdlib.h functions wrappers so check for it separately:
1257
#if defined(__MINGW32__) && wxUSE_UNICODE && !defined(_tsystem)
1258
#define wxNEED_WXSYSTEM
1261
#ifdef wxNEED_WX_STDLIB_H
1262
WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz);
1263
WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz);
1264
WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name);
1265
#define wxNEED_WXSYSTEM
1268
#ifdef wxNEED_WXSYSTEM
1269
WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
1273
/* time.h functions */
1274
#ifdef wxNEED_WX_TIME_H
1275
#if defined(__MWERKS__) && defined(macintosh)
1278
/*silent gabby compilers*/
1280
WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
1281
const wxChar *fmt, const struct tm *tm);
1282
#endif /* wxNEED_WX_TIME_H */
1286
WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep);
1290
/* missing functions in some WinCE versions */
1292
#if (_WIN32_WCE < 300)
1293
WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
1295
#endif /* _WIN32_WCE */
1297
/* multibyte to wide char conversion functions and macros */
1300
/* multibyte<->widechar conversion */
1301
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
1302
WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1305
#define wxMB2WX wxMB2WC
1306
#define wxWX2MB wxWC2MB
1307
#define wxWC2WX wxStrncpy
1308
#define wxWX2WC wxStrncpy
1310
#define wxMB2WX wxStrncpy
1311
#define wxWX2MB wxStrncpy
1312
#define wxWC2WX wxWC2MB
1313
#define wxWX2WC wxMB2WC
1315
#else /* !wxUSE_UNICODE */
1316
/* Why is this here?
1318
/* No wxUSE_WCHAR_T: we have to do something (JACS) */
1319
#define wxMB2WC wxStrncpy
1320
#define wxWC2MB wxStrncpy
1321
#define wxMB2WX wxStrncpy
1322
#define wxWX2MB wxStrncpy
1323
#define wxWC2WX wxWC2MB
1324
#define wxWX2WC wxMB2WC
1328
RN: The following are not normal versions of memcpy et al., rather
1329
these are either char or widechar versions depending on
1330
if unicode is used or not.
1336
// RN: We could do the usual tricky compiler detection here,
1337
// and use their variant (such as wmemchr, etc.). The problem
1338
// is that these functions are quite rare, even though they are
1339
// part of the current POSIX standard. In addition, most compilers
1340
// (including even MSC) inline them just like we do right in their
1345
//implement our own wmem variants
1346
inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
1348
for(;l && *s != c;--l, ++s) {}
1355
inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
1357
for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
1360
return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
1365
inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
1367
return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
1370
inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
1372
return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
1375
inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len)
1377
wxChar* szRet = szOut;
1384
#else /* !wxUSE_UNICODE */
1385
#if wxABI_VERSION >= 20805
1386
// for compatibility with earlier versions, these functions take
1387
// "void *" but in the next wx version they will take "char *" so
1388
// don't use them with void pointers (use the standard memxxx()
1390
inline char* wxTmemchr(const void* s, int c, size_t len)
1391
{ return (char*)memchr(s, c, len); }
1392
inline int wxTmemcmp(const void* sz1, const void* sz2, size_t len)
1393
{ return memcmp(sz1, sz2, len); }
1394
inline char* wxTmemcpy(void* szOut, const void* szIn, size_t len)
1395
{ return (char*)memcpy(szOut, szIn, len); }
1396
inline char* wxTmemmove(void* szOut, const void* szIn, size_t len)
1397
{ return (char*)memmove(szOut, szIn, len); }
1398
inline char* wxTmemset(void* szOut, int c, size_t len)
1399
{ return (char*)memset(szOut, c, len); }
1401
# define wxTmemchr memchr
1402
# define wxTmemcmp memcmp
1403
# define wxTmemcpy memcpy
1404
# define wxTmemmove memmove
1405
# define wxTmemset memset
1407
#endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
1409
#endif /*__cplusplus*/
1412
#endif /* _WX_WXCHAR_H_ */