]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wxchar.h
Ctrl+mouse wheel changes zoom factor in print preview (patch 1230919)
[wxWidgets.git] / include / wx / wxchar.h
1 /*
2 * Name: wx/wxchar.h
3 * Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4 * Author: Joel Farley, Ove Kåven
5 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
6 * Created: 1998/06/12
7 * RCS-ID: $Id$
8 * Copyright: (c) 1998-2002 Joel Farley, Ove Kåven, Robert Roebling, Ron Lee
9 * Licence: wxWindows licence
10 */
11
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14 #ifndef _WX_WXCHAR_H_
15 #define _WX_WXCHAR_H_
16
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "wxchar.h"
19 #endif
20
21 #include "wx/defs.h" /* for wxUSE_UNICODE */
22
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 **);
25 #endif
26
27 /* check whether we have wchar_t and which size it is if we do */
28 #if !defined(wxUSE_WCHAR_T)
29 #if defined(__UNIX__)
30 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
31 #define wxUSE_WCHAR_T 1
32 #else
33 #define wxUSE_WCHAR_T 0
34 #endif
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
41 #else
42 /* add additional compiler checks if this fails */
43 #define wxUSE_WCHAR_T 1
44 #endif
45 #endif /* !defined(wxUSE_WCHAR_T) */
46
47 /* Unicode support requires wchar_t */
48 #if wxUSE_UNICODE && !wxUSE_WCHAR_T
49 #error "wchar_t must be available in Unicode build"
50 #endif /* Unicode */
51
52 /*
53 Standard headers we need here.
54
55 NB: don't include any wxWidgets headers here because almost of them include
56 this one!
57 */
58
59 /* Required for wxPrintf() etc */
60 #include <stdarg.h>
61
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(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
65 /* use #define, not inline wrapper, as it is tested with #ifndef below */
66 #define wxStrdupA strdup
67 #endif
68
69 /*
70 non Unix compilers which do have wchar.h (but not tchar.h which is included
71 below and which includes wchar.h anyhow).
72
73 Actually MinGW has tchar.h, but it does not include wchar.h
74 */
75 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
76 #ifndef HAVE_WCHAR_H
77 #define HAVE_WCHAR_H
78 #endif
79 #endif
80 #if defined(__MWERKS__) && !defined(__MACH__)
81 #ifndef HAVE_WCSLEN
82 #define HAVE_WCSLEN
83 #endif
84 #endif
85
86 #if wxUSE_WCHAR_T
87 #ifdef HAVE_WCHAR_H
88 /* the current (as of Nov 2002) version of cygwin has a bug in its */
89 /* wchar.h -- there is no extern "C" around the declarations in it and */
90 /* this results in linking errors later; also, at least on some */
91 /* Cygwin versions, wchar.h requires sys/types.h */
92 #ifdef __CYGWIN__
93 #include <sys/types.h>
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 #endif /* Cygwin */
98
99 #include <wchar.h>
100
101 #if defined(__CYGWIN__) && defined(__cplusplus)
102 }
103 #endif /* Cygwin and C++ */
104
105 #elif defined(HAVE_WCSTR_H)
106 /* old compilers have relevant declarations here */
107 #include <wcstr.h>
108 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
109 /* include stdlib.h for wchar_t */
110 #include <stdlib.h>
111 #endif /* HAVE_WCHAR_H */
112 #endif /* wxUSE_WCHAR_T */
113
114 /* ---------------------------------------------------------------------------- */
115 /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
116 /* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
117 /* the function mapping _tfoo() -> foo() or wfoo() */
118 /* ---------------------------------------------------------------------------- */
119
120 /* VC++ and BC++ starting with 5.2 have TCHAR support */
121 #ifdef __VISUALC__
122 #define wxHAVE_TCHAR_SUPPORT
123 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
124 #define wxHAVE_TCHAR_SUPPORT
125 #include <ctype.h>
126 #elif defined(__WATCOMC__)
127 #define wxHAVE_TCHAR_SUPPORT
128 #elif defined(__DMC__)
129 #define wxHAVE_TCHAR_SUPPORT
130 #elif defined(__WXPALMOS__)
131 #include <stddef.h>
132 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
133 #define wxHAVE_TCHAR_SUPPORT
134 #include <stddef.h>
135 #include <string.h>
136 #include <ctype.h>
137 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
138 /* VZ: the old VisualAge definitions were completely wrong and had no */
139 /* chance at all to work in Unicode build anyhow so let's pretend that */
140 /* VisualAge does _not_ support TCHAR for the moment (as indicated by */
141 /* "0 &&" above) until someone really has time to delve into Unicode */
142 /* issues under OS/2 */
143
144 /* VisualAge 4.0+ supports TCHAR */
145 #define wxHAVE_TCHAR_SUPPORT
146 #endif /* compilers with (good) TCHAR support */
147
148 #ifdef __MWERKS__
149 #define HAVE_WPRINTF
150 #endif
151
152 #ifdef wxHAVE_TCHAR_SUPPORT
153 /* get TCHAR definition if we've got it */
154 #include <tchar.h>
155
156 /* we surely do have wchar_t if we have TCHAR */
157 #ifndef wxUSE_WCHAR_T
158 #define wxUSE_WCHAR_T 1
159 #endif /* !defined(wxUSE_WCHAR_T) */
160
161 /* and we also do have wcslen() */
162 #ifndef HAVE_WCSLEN
163 #define HAVE_WCSLEN
164 #endif
165 #endif /* wxHAVE_TCHAR_SUPPORT */
166
167 /* ---------------------------------------------------------------------------- */
168 /* define wxChar type */
169 /* ---------------------------------------------------------------------------- */
170
171 /* TODO: define wxCharInt to be equal to either int or wint_t? */
172
173 #if !wxUSE_UNICODE
174 typedef char wxChar;
175 typedef signed char wxSChar;
176 typedef unsigned char wxUChar;
177 #else /* Unicode */
178 /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
179 /* signed/unsigned version of it which (a) makes sense to me (unlike */
180 /* char wchar_t is always unsigned) and (b) was how the previous */
181 /* definitions worked so keep it like this */
182
183 /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
184 /* comment below */
185 #if !defined(__WCHAR_TYPE__) || \
186 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
187 /* standard case */
188 typedef wchar_t wxChar;
189 typedef wchar_t wxSChar;
190 typedef wchar_t wxUChar;
191 #else /* __WCHAR_TYPE__ and gcc < 2.96 */
192 /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. However, */
193 /* this doesn't work with new GCC 3.x compilers because wchar_t is */
194 /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */
195 /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */
196 /* have to define wxChar conditionally depending on detected */
197 /* compiler & compiler version. */
198 /* with old definition of wxChar. */
199 typedef __WCHAR_TYPE__ wxChar;
200 typedef __WCHAR_TYPE__ wxSChar;
201 typedef __WCHAR_TYPE__ wxUChar;
202 #endif /* __WCHAR_TYPE__ */
203 #endif /* ASCII/Unicode */
204
205 /* ---------------------------------------------------------------------------- */
206 /* define _T() and related macros */
207 /* ---------------------------------------------------------------------------- */
208
209 /* BSD systems define _T() to be something different in ctype.h, override it */
210 #if defined(__FreeBSD__) || defined(__DARWIN__)
211 #include <ctype.h>
212 #undef _T
213 #endif
214
215 /* could already be defined by tchar.h (it's quasi standard) */
216 #ifndef _T
217 #if !wxUSE_UNICODE
218 #define _T(x) x
219 #else /* Unicode */
220 #define _T(x) L ## x
221 #endif /* ASCII/Unicode */
222 #endif /* !defined(_T) */
223
224 /* although global macros with such names are normally bad, we want to have */
225 /* another name for _T() which should be used to avoid confusion between _T() */
226 /* and _() in wxWidgets sources */
227 #define wxT(x) _T(x)
228
229 /* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
230 #ifndef __TFILE__
231 #define __XFILE__(x) wxT(x)
232 #define __TFILE__ __XFILE__(__FILE__)
233 #endif
234
235 #ifndef __TDATE__
236 #define __XDATE__(x) wxT(x)
237 #define __TDATE__ __XDATE__(__DATE__)
238 #endif
239
240 #ifndef __TTIME__
241 #define __XTIME__(x) wxT(x)
242 #define __TTIME__ __XTIME__(__TIME__)
243 #endif
244
245 /*
246 define wxFoo() function for each standard foo() function whose signature
247 (exceptionally including the return type) includes any mention of char:
248 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
249 the same signature but with char replaced by wxChar which allows us to use
250 it in Unicode build as well
251 */
252
253 #ifdef wxHAVE_TCHAR_SUPPORT
254 #include <ctype.h>
255
256 #if defined(__WATCOMC__) && defined(UNICODE)
257 #define WXWCHAR_T_CAST(c) (wint_t)(c)
258 #else
259 #define WXWCHAR_T_CAST(c) c
260 #endif
261
262 /* ctype.h functions */
263 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
264 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
265 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
266 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
267 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
268 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
269 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
270 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
271 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
272 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
273 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
274
275 /*
276 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
277 signed chars < 0, so "fix" it here.
278 */
279 #define wxTolower(c) _totlower((wxUChar)(c))
280 #define wxToupper(c) _totupper((wxUChar)(c))
281
282 /* locale.h functons */
283 #define wxSetlocale _tsetlocale
284
285 /* string.h functions */
286 #define wxStrcat _tcscat
287 #define wxStrchr _tcschr
288 #define wxStrcmp _tcscmp
289 #define wxStrcoll _tcscoll
290 #define wxStrcpy _tcscpy
291 #define wxStrcspn _tcscspn
292 #define wxStrdupW _wcsdup /* notice the 'W'! */
293 #define wxStrftime _tcsftime
294 #define wxStricmp _tcsicmp
295 #define wxStrnicmp _tcsnicmp
296 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
297 #define wxStrncat _tcsncat
298 #define wxStrncmp _tcsncmp
299 #define wxStrncpy _tcsncpy
300 #define wxStrpbrk _tcspbrk
301 #define wxStrrchr _tcsrchr
302 #define wxStrspn _tcsspn
303 #define wxStrstr _tcsstr
304 #define wxStrtod _tcstod
305 #define wxStrtol _tcstol
306 #define wxStrtoul _tcstoul
307 #define wxStrxfrm _tcsxfrm
308
309 /* stdio.h functions */
310 #define wxFgetc _fgettc
311 #define wxFgetchar _fgettchar
312 #define wxFgets _fgetts
313 #if wxUSE_UNICODE_MSLU
314 #define wxFopen wxMSLU__tfopen
315 #else
316 #define wxFopen _tfopen
317 #endif
318 #define wxFputc _fputtc
319 #define wxFputchar _fputtchar
320 #define wxFprintf _ftprintf
321 #define wxFputs _fputts
322 #define wxFreopen _tfreopen
323 #define wxFscanf _ftscanf
324 #define wxGetc _gettc
325 #define wxGetchar _gettchar
326 #define wxGets _getts
327 #define wxPerror _tperror
328 #define wxPrintf _tprintf
329 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
330 #define wxPutchar _puttchar
331 #define wxPuts _putts
332 #define wxScanf _tscanf
333 #if defined(__DMC__)
334 #if wxUSE_UNICODE
335 /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
336 int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
337 #else
338 /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
339 #define wxSprintf sprintf
340 #endif
341 #else
342 #define wxSprintf _stprintf
343 #endif
344
345 #define wxSscanf _stscanf
346 #define wxTmpnam _ttmpnam
347 #define wxUngetc _tungetc
348 #define wxVfprintf _vftprintf
349 #define wxVprintf _vtprintf
350 #define wxVsscanf _vstscanf
351 #define wxVsprintf _vstprintf
352
353 /* special case: not all TCHAR-aware compilers have those */
354 #if defined(__VISUALC__) || \
355 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
356 #define wxVsnprintf_ _vsntprintf
357 #define wxSnprintf_ _sntprintf
358 #endif
359
360 /* special case: these functions are missing under Win9x with Unicows so we */
361 /* have to implement them ourselves */
362 #if wxUSE_UNICODE_MSLU
363 #define wxRemove wxMSLU__tremove
364 #define wxRename wxMSLU__trename
365 #else
366 #ifdef __WXWINCE__
367 /* carefully: wxRemove() must return 0 on success while DeleteFile()
368 returns 0 on error, so don't just define one as the other */
369 int wxRemove(const wxChar *path);
370 #else
371 #define wxRemove _tremove
372 #define wxRename _trename
373 #endif
374 #endif
375
376 /* stdlib.h functions */
377 #define wxAtoi _ttoi
378 #define wxAtol _ttol
379 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
380 /* there are no env vars at all under CE, so no _tgetenv neither */
381 #ifdef __WXWINCE__
382 /* can't define as inline function as this is a C file... */
383 #define wxGetenv(name) ((wxChar *)NULL)
384 #else
385 #define wxGetenv _tgetenv
386 #endif
387 #define wxSystem _tsystem
388
389 /* time.h functions */
390 #define wxAsctime _tasctime
391 #define wxCtime _tctime
392
393 #define wxMbstowcs mbstowcs
394 #define wxWcstombs wcstombs
395 #else /* !TCHAR-aware compilers */
396
397 #if !defined(__MWERKS__) && defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
398 /* even though they are defined and "implemented", they are bad and just
399 stubs so we need our own - we need these even in ANSI builds!! */
400 WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t);
401 WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t);
402 #else
403 #define wxMbstowcs mbstowcs
404 #define wxWcstombs wcstombs
405 #endif
406
407 /* No UNICODE in the c library except wchar_t typedef on mac OSX 10.2 and less - roll our own */
408 #if !defined(__MWERKS__) && wxUSE_UNICODE && defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
409
410 /* we need everything! */
411 #define wxNEED_WX_STRING_H
412 #define wxNEED_WX_CTYPE_H
413
414 #define wxFgetchar(c) wxFgetc(c, stdin)
415 #define wxFputc wxPutc
416 #define wxFputchar(c) wxPutc(c, stdout)
417 #define wxGetc wxFgetc
418 #define wxGetchar(c) wxFgetc(c, stdin)
419
420 #include <stdio.h>
421
422 #define wxNEED_FGETC
423 #define wxNEED_FGETS
424 #define wxNEED_GETS
425 #define wxNEED_UNGETC
426
427 #define wxNEED_FPUTS
428 #define wxNEED_PUTS
429 #define wxNEED_PUTC
430
431 int wxFputs(const wxChar *ch, FILE *stream);
432 int wxPuts(const wxChar *ws);
433 int wxPutc(wxChar ch, FILE *stream);
434
435 #ifdef __cplusplus
436 extern "C" {
437 #endif
438 WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
439 #ifdef __cplusplus
440 }
441 #endif
442
443 #define wxPutchar(wch) wxPutc(wch, stdout)
444
445 #define wxNEED_PRINTF_CONVERSION
446 #define wxNEED_WX_STDIO_H
447 #define wxNEED_WX_STDLIB_H
448 #define wxNEED_WX_TIME_H
449
450 #elif wxUSE_UNICODE
451 #include <wctype.h>
452
453 /* this is probably glibc-specific */
454 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
455 /* ctype.h functions (wctype.h) */
456 #define wxIsalnum iswalnum
457 #define wxIsalpha iswalpha
458 #define wxIscntrl iswcntrl
459 #define wxIsdigit iswdigit
460 #define wxIsgraph iswgraph
461 #define wxIslower iswlower
462 #define wxIsprint iswprint
463 #define wxIspunct iswpunct
464 #define wxIsspace iswspace
465 #define wxIsupper iswupper
466 #define wxIsxdigit iswxdigit
467
468 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
469 /* /usr/include/wctype.h incorrectly declares translations */
470 /* tables which provokes tons of compile-time warnings -- try */
471 /* to correct this */
472 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
473 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
474 #else /* !glibc 2.0 */
475 #define wxTolower towlower
476 #define wxToupper towupper
477 #endif /* gcc/!gcc */
478
479 /* string.h functions (wchar.h) */
480 #define wxStrcat wcscat
481 #define wxStrchr wcschr
482 #define wxStrcmp wcscmp
483 #define wxStrcoll wcscoll
484 #define wxStrcpy wcscpy
485 #define wxStrcspn wcscspn
486 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
487 #define wxStrncat wcsncat
488 #define wxStrncmp wcsncmp
489 #define wxStrncpy wcsncpy
490 #define wxStrpbrk wcspbrk
491 #define wxStrrchr wcsrchr
492 #define wxStrspn wcsspn
493 #define wxStrstr wcsstr
494 #define wxStrtod wcstod
495 #define wxStrtol wcstol
496 #define wxStrtoul wcstoul
497 #define wxStrxfrm wcsxfrm
498
499 #define wxFgetc fgetwc
500 #define wxFgetchar fgetwchar
501 #define wxFgets fgetws
502 #define wxFputc fputwc
503 #define wxFputchar fputwchar
504 #define wxGetc getwc
505 #define wxGetchar getwchar
506 #define wxGets getws
507 #define wxUngetc ungetwc
508
509 #ifdef HAVE_FPUTWS
510 #define wxFputs fputws
511 #else
512 #define wxNEED_FPUTS
513 #include <stdio.h>
514 int wxFputs(const wxChar *ch, FILE *stream);
515 #endif
516
517 #ifdef HAVE_WPUTC
518 #define wxPutc wputc
519 #else
520 #define wxNEED_PUTC
521 #include <stdio.h>
522 int wxPutc(wxChar ch, FILE *stream);
523 #endif
524
525 #ifdef HAVE_WPUTCHAR
526 #define wxPutchar wputchar
527 #else
528 #define wxPutchar(wch) wxPutc(wch, stdout)
529 #endif
530
531 #ifdef HAVE_PUTWS
532 #define wxPuts putws
533 #else
534 #define wxNEED_PUTS
535 int wxPuts(const wxChar *ws);
536 #endif
537
538 /* we need %s to %ls conversion for printf and scanf etc */
539 #define wxNEED_PRINTF_CONVERSION
540
541 /* glibc doesn't have wide char equivalents of the other stuff so */
542 /* use our own versions */
543 #define wxNEED_WX_STDIO_H
544 #define wxNEED_WX_STDLIB_H
545 #define wxNEED_WX_TIME_H
546 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
547 /* ctype.h functions (wctype.h) */
548 #define wxIsalnum iswalnum
549 #define wxIsalpha iswalpha
550 #define wxIscntrl iswcntrl
551 #define wxIsdigit iswdigit
552 #define wxIsgraph iswgraph
553 #define wxIslower iswlower
554 #define wxIsprint iswprint
555 #define wxIspunct iswpunct
556 #define wxIsspace iswspace
557 #define wxIsupper iswupper
558 #define wxIsxdigit iswxdigit
559 #define wxTolower towlower
560 #define wxToupper towupper
561
562 /* string.h functions (wchar.h) */
563 #define wxStrcat wcscat
564 #define wxStrchr wcschr
565 #define wxStrcmp wcscmp
566 #define wxStrcoll wcscoll
567 #define wxStrcpy wcscpy
568 #define wxStrcspn wcscspn
569 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
570 #define wxStrncat wcsncat
571 #define wxStrncmp wcsncmp
572 #define wxStrncpy wcsncpy
573 #define wxStrpbrk wcspbrk
574 #define wxStrrchr wcsrchr
575 #define wxStrspn wcsspn
576 #define wxStrstr wcsstr
577 #define wxStrtod wcstod
578 #define wxStrtol wcstol
579 #define wxStrtoul wcstoul
580 #define wxStrxfrm wcsxfrm
581
582 #define wxFgetc fgetwc
583 #define wxFgetchar fgetwchar
584 #define wxFgets fgetws
585 #define wxFputc fputwc
586 #define wxFputchar fputwchar
587 #define wxGetc getwc
588 #define wxGetchar getwchar
589 #define wxGets getws
590 #define wxUngetc ungetwc
591
592 #define wxNEED_PRINTF_CONVERSION
593
594 #define wxPutc putwc
595 #define wxPutchar putwchar
596 #define wxFputs fputws
597
598 /* stdio.h functions */
599
600 #define wxNEED_WX_STDIO_H
601
602 /* stdlib.h functions */
603 #ifdef __MACH__
604 #define wxNEED_WX_STDLIB_H
605 #else
606 #define wxAtof watof
607 #define wxAtoi watoi
608 #define wxAtol watol
609 #define wxGetenv(a) ((wxChar*)NULL)
610 #define wxSystem(a) ((int)NULL)
611 #endif
612 /* time.h functions */
613 #define wxAsctime wasciitime
614 #define wxCtime wctime
615 /* #define wxStrftime wcsftime */
616
617 #define wxNEED_WX_TIME_H
618 #else /* !metrowerks for apple */
619 #error "Please define wide character functions for your environment"
620 #endif
621 #else /* ASCII */
622 #include <ctype.h>
623 #include <string.h>
624
625 /* ctype.h functions */
626 #define wxIsalnum isalnum
627 #define wxIsalpha isalpha
628 #define wxIscntrl iscntrl
629 #define wxIsdigit isdigit
630 #define wxIsgraph isgraph
631 #define wxIslower islower
632 #define wxIsprint isprint
633 #define wxIspunct ispunct
634 #define wxIsspace isspace
635 #define wxIsupper isupper
636 #define wxIsxdigit isxdigit
637 #define wxTolower tolower
638 #define wxToupper toupper
639
640 /* locale.h functons */
641 #define wxSetlocale setlocale
642
643 /* string.h functions */
644 #define wxStrcat strcat
645 #define wxStrchr strchr
646 #define wxStrcmp strcmp
647 #define wxStrcoll strcoll
648 #define wxStrcpy strcpy
649 #define wxStrcspn strcspn
650
651 /* wxStricmp and wxStrnicmp are defined below */
652 #define wxStrlen_ strlen /* used in wxStrlen inline function */
653 #define wxStrncat strncat
654 #define wxStrncmp strncmp
655 #define wxStrncpy strncpy
656 #define wxStrpbrk strpbrk
657 #define wxStrrchr strrchr
658 #define wxStrspn strspn
659 #define wxStrstr strstr
660 #define wxStrtod strtod
661 #ifdef HAVE_STRTOK_R
662 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
663 #endif
664 #define wxStrtol strtol
665 #define wxStrtoul strtoul
666 #define wxStrxfrm strxfrm
667
668 /* stdio.h functions */
669 #define wxFopen fopen
670 #define wxFreopen freopen
671 #define wxRemove remove
672 #define wxRename rename
673
674 #define wxPerror perror
675 #define wxTmpnam tmpnam
676
677 #define wxFgetc fgetc
678 #define wxFgetchar fgetchar
679 #define wxFgets fgets
680 #define wxFputc fputc
681 #define wxFputs fputs
682 #define wxFputchar fputchar
683 #define wxFprintf fprintf
684 #define wxFscanf fscanf
685 #define wxGetc getc
686 #define wxGetchar getchar
687 #define wxGets gets
688 #define wxPrintf printf
689 #define wxPutc putc
690 #define wxPutchar putchar
691 #define wxPuts puts
692 #define wxScanf scanf
693 #define wxSprintf sprintf
694 #define wxSscanf sscanf
695 #define wxUngetc ungetc
696 #define wxVfprintf vfprintf
697 #define wxVprintf vprintf
698 #define wxVsscanf vsscanf
699 #define wxVsprintf vsprintf
700
701 /* stdlib.h functions */
702 #define wxAtof atof
703 #define wxAtoi atoi
704 #define wxAtol atol
705 #define wxGetenv getenv
706 #define wxSystem system
707
708 /* time.h functions */
709 #define wxAsctime asctime
710 #define wxCtime ctime
711 #define wxStrftime strftime
712 #endif /* Unicode/ASCII */
713 #endif /* TCHAR-aware compilers/the others */
714
715 /*
716 various special cases
717 */
718
719 /* define wxStricmp and wxStrnicmp for various compilers */
720
721 /* note that in Unicode mode we definitely are going to need our own version */
722 #if !defined(wxStricmp) && !wxUSE_UNICODE
723 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
724 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
725 defined(__EMX__) || defined(__DJGPP__)
726 #define wxStricmp stricmp
727 #define wxStrnicmp strnicmp
728 #elif defined(__WXPALMOS__)
729 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
730 * quick hack should do until one can be written.
731 */
732 #define wxStricmp StrCaselessCompare
733 #define wxStrnicmp strnicmp
734 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
735 (defined(__MWERKS__) && defined(__INTEL__))
736 #define wxStricmp _stricmp
737 #define wxStrnicmp _strnicmp
738 #elif defined(__UNIX__) || defined(__GNUWIN32__)
739 #define wxStricmp strcasecmp
740 #define wxStrnicmp strncasecmp
741 /* #else -- use wxWidgets implementation */
742 #endif
743 #endif /* !defined(wxStricmp) */
744
745 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
746 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
747 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
748 #if wxUSE_WCHAR_T
749 #ifdef HAVE_WCSLEN
750 #define wxWcslen wcslen
751 #else
752 WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s);
753 #endif
754 #endif /* wxUSE_WCHAR_T */
755
756 #ifdef __cplusplus
757 /* checks whether the passed in pointer is NULL and if the string is empty */
758 inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
759
760 /* safe version of strlen() (returns 0 if passed NULL pointer) */
761 inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; }
762 #endif
763
764 /*
765 each of strdup() and wcsdup() may or may not be available but we need both
766 of them anyhow for wx/buffer.h so we define the missing one(s) in
767 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
768 defined -- if this is somehow not the case in some situations, please
769 correct that and not the lines here
770 */
771 #if wxUSE_UNICODE
772 #define wxStrdup wxStrdupW
773 #else
774 #define wxStrdup wxStrdupA
775 #endif
776
777 #ifdef __cplusplus
778 WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
779 #endif
780
781 /* printf() family saga */
782
783 /*
784 For some systems vsnprintf() exists in the system libraries but not in the
785 headers, so we need to declare it ourselves to be able to use it.
786 */
787 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
788 #ifdef __cplusplus
789 extern "C"
790 #else
791 extern
792 #endif
793 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
794 #endif /* !HAVE_VSNPRINTF_DECL */
795
796 /*
797 First of all, we always want to define safe snprintf() function to be used
798 instead of sprintf(). Some compilers already have it (or rather vsnprintf()
799 which we really need...), otherwise we implement it using our own printf()
800 code.
801
802 We define function with a trailing underscore here because the real one is a
803 wrapper around it as explained below
804 */
805 #ifndef wxVsnprintf_
806 #if wxUSE_UNICODE
807 #if defined(__MWERKS__)
808 #define HAVE_WCSRTOMBS 1
809 #define HAVE_VSWPRINTF 1
810 #endif
811 #if defined(__WATCOMC__)
812 #define wxVsnprintf_ _vsnwprintf
813 #define wxSnprintf_ _snwprintf
814 #endif
815 #if defined(HAVE__VSNWPRINTF)
816 #define wxVsnprintf_ _vsnwprintf
817 /* MinGW?MSVCRT has the wrong vswprintf */
818 #elif defined(HAVE_VSWPRINTF) && !defined(__MINGW32__)
819 #define wxVsnprintf_ vswprintf
820 #endif
821 #else /* ASCII */
822 /* all versions of CodeWarrior supported by wxWidgets apparently have */
823 /* vsnprintf() */
824 #if defined(HAVE_VSNPRINTF) || defined(__MWERKS__) || defined(__WATCOMC__)
825 /* assume we have snprintf() too if we have vsnprintf() */
826 #define wxVsnprintf_ vsnprintf
827 #define wxSnprintf_ snprintf
828 #endif
829 #endif
830 #endif /* wxVsnprintf_ not defined yet */
831
832 #ifndef wxSnprintf_
833 /* no [v]snprintf(), cook our own */
834 WXDLLIMPEXP_BASE int wxSnprintf_(wxChar *buf, size_t len, const wxChar *format,
835 ...) ATTRIBUTE_PRINTF_3;
836 #endif
837 #ifndef wxVsnprintf_
838 WXDLLIMPEXP_BASE int wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format,
839 va_list argptr);
840 #endif
841
842 /*
843 In Unicode mode we need to have all standard functions such as wprintf() and
844 so on but not all systems have them so use our own implementations in this
845 case.
846 */
847 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
848 #define wxNEED_WPRINTF
849 #endif
850
851 /*
852 More Unicode complications: although both ANSI C and C++ define a number of
853 wide character functions such as wprintf(), not all environments have them.
854 Worse, those which do have different behaviours: under Windows, %s format
855 specifier changes its meaning in Unicode build and expects a Unicode string
856 while under Unix/POSIX it still means an ASCII string even for wprintf() and
857 %ls has to be used for wide strings.
858
859 We choose to always emulate Windows behaviour as more useful for us so even
860 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
861
862 */
863
864 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
865 /*
866 we need to implement all wide character printf and scanf functions
867 either because we don't have them at all or because they don't have the
868 semantics we need
869 */
870
871 #include <stdio.h> /* for FILE */
872
873 int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
874 int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
875 int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
876 int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
877 int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
878 int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
879 int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
880 int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
881 int wxVprintf( const wxChar *format, va_list ap );
882 int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
883 #endif /* wxNEED_PRINTF_CONVERSION */
884
885 /* these 2 can be simply mapped to the versions with underscore at the end */
886 /* if we don't have to do the conversion */
887 /*
888 However, if we don't have any vswprintf() at all we don't need to redefine
889 anything as our own wxVsnprintf_() already behaves as needed.
890 */
891 #if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
892 int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
893 int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
894 #else
895 #define wxSnprintf wxSnprintf_
896 #define wxVsnprintf wxVsnprintf_
897 #endif
898
899 /*
900 various functions which might not be available in libc and for which we
901 provide our own replacements in wxchar.cpp
902 */
903
904 /* ctype.h functions */
905
906 /* RN: Used only under OSX <= 10.2 currently */
907 #ifdef wxNEED_WX_CTYPE_H
908 WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
909 WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
910 WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch);
911 WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
912 WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
913 WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
914 WXDLLIMPEXP_BASE int wxIsprint(wxChar ch);
915 WXDLLIMPEXP_BASE int wxIspunct(wxChar ch);
916 WXDLLIMPEXP_BASE int wxIsspace(wxChar ch);
917 WXDLLIMPEXP_BASE int wxIsupper(wxChar ch);
918 WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
919 WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
920 WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
921 #endif /* wxNEED_WX_CTYPE_H */
922
923 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
924 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
925 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
926 #undef wxIsspace
927 #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
928 #endif /* VC++ */
929
930 /*
931 a few compilers don't have the (non standard but common) isascii function,
932 define it ourselves for them
933 */
934 #ifndef isascii
935 #if defined(__MWERKS__)
936 #define wxNEED_ISASCII
937 #elif defined(_WIN32_WCE)
938 #if _WIN32_WCE <= 211
939 #define wxNEED_ISASCII
940 #endif
941 #endif
942 #endif /* isascii */
943
944 #ifdef wxNEED_ISASCII
945 inline int isascii(int c) { return (unsigned)c < 0x80; }
946 #endif
947
948 #ifdef _WIN32_WCE
949 #if _WIN32_WCE <= 211
950 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
951 #endif
952 #endif /* _WIN32_WCE */
953
954 /*
955 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
956 initial versions of this header -- now it is too late to remove it so
957 although we fixed the function/macro name above, still provide the
958 backwards-compatible synonym.
959 */
960 #define wxIsctrl wxIscntrl
961
962 /* string.h functions */
963 #ifndef strdup
964 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
965 #define wxNEED_STRDUP
966 #elif defined(__WXWINCE__)
967 #if _WIN32_WCE <= 211
968 #define wxNEED_STRDUP
969 #endif
970 #endif
971 #endif /* strdup */
972
973 #ifdef wxNEED_STRDUP
974 WXDLLIMPEXP_BASE char *strdup(const char* s);
975 #endif
976
977 /* RN: Used only under OSX <= 10.2 currently
978 The __cplusplus ifdefs are messy, but they are required to build
979 the regex library, since c does not support function overloading
980 */
981 #ifdef wxNEED_WX_STRING_H
982 # ifdef __cplusplus
983 extern "C" {
984 # endif
985 WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
986 WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
987 WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
988 WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
989 WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
990 WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
991 WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
992 WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
993 WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
994 WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
995 WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
996 WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
997 WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
998 # ifdef __cplusplus
999 }
1000 # endif
1001
1002 /* These functions use C++, so we can't c extern them */
1003 WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
1004 WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
1005 WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
1006 WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
1007
1008 /* inlined versions */
1009 #ifdef __cplusplus
1010 inline wxChar * wxStrchr(wxChar *s, wxChar c)
1011 { return (wxChar *)wxStrchr((const wxChar *)s, c); }
1012 inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
1013 { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
1014 inline wxChar * wxStrrchr(wxChar *s, wxChar c)
1015 { return (wxChar *)wxStrrchr((const wxChar *)s, c); }
1016 inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
1017 { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
1018 #endif
1019
1020 #endif /* wxNEED_WX_STRING_H */
1021
1022 #ifndef wxStrdupA
1023 WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz);
1024 #endif
1025
1026 #ifndef wxStrdupW
1027 WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz);
1028 #endif
1029
1030 #ifndef wxStricmp
1031 WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2);
1032 #endif
1033
1034 #ifndef wxStrnicmp
1035 WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len);
1036 #endif
1037
1038 #ifndef wxStrtok
1039 WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
1040 #endif
1041
1042 #ifdef __cplusplus
1043 #ifndef wxSetlocale
1044 class WXDLLIMPEXP_BASE wxWCharBuffer;
1045 WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale);
1046 #endif
1047 #endif
1048
1049 /* stdio.h functions */
1050 #ifdef wxNEED_WX_STDIO_H
1051 #include <stdio.h>
1052 WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
1053 WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
1054 WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
1055 WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
1056
1057 /* *printf() family is handled separately */
1058 #endif /* wxNEED_WX_STDIO_H */
1059
1060
1061 /* stdlib.h functions */
1062 #ifndef wxAtof
1063 WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz);
1064 #endif
1065
1066 #ifdef wxNEED_WX_STDLIB_H
1067 WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz);
1068 WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz);
1069 WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name);
1070 WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
1071 #endif
1072
1073
1074 /* time.h functions */
1075 #ifdef wxNEED_WX_TIME_H
1076 #if defined(__MWERKS__) && defined(macintosh)
1077 #include <time.h>
1078 #endif
1079 /*silent gabby compilers*/
1080 struct tm;
1081 WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
1082 const wxChar *fmt, const struct tm *tm);
1083 #endif /* wxNEED_WX_TIME_H */
1084
1085 #ifndef wxCtime
1086 #include <time.h>
1087 WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep);
1088 #endif
1089
1090
1091 /* missing functions in some WinCE versions */
1092 #ifdef _WIN32_WCE
1093 #if (_WIN32_WCE < 300)
1094 WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
1095 #endif
1096 #endif /* _WIN32_WCE */
1097
1098 /* multibyte to wide char conversion functions and macros */
1099
1100 #if wxUSE_WCHAR_T
1101 /* multibyte<->widechar conversion */
1102 WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
1103 WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1104
1105 #if wxUSE_UNICODE
1106 #define wxMB2WX wxMB2WC
1107 #define wxWX2MB wxWC2MB
1108 #define wxWC2WX wxStrncpy
1109 #define wxWX2WC wxStrncpy
1110 #else
1111 #define wxMB2WX wxStrncpy
1112 #define wxWX2MB wxStrncpy
1113 #define wxWC2WX wxWC2MB
1114 #define wxWX2WC wxMB2WC
1115 #endif
1116 #else /* !wxUSE_UNICODE */
1117 /* Why is this here?
1118 #error ha */
1119 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
1120 #define wxMB2WC wxStrncpy
1121 #define wxWC2MB wxStrncpy
1122 #define wxMB2WX wxStrncpy
1123 #define wxWX2MB wxStrncpy
1124 #define wxWC2WX wxWC2MB
1125 #define wxWX2WC wxMB2WC
1126 #endif
1127
1128 /*
1129 RN: The following are not normal versions of memcpy et al., rather
1130 these are either char or widechar versions depending on
1131 if unicode is used or not.
1132 */
1133
1134 #ifdef __cplusplus
1135
1136 //
1137 // RN: We could do the usual tricky compiler detection here,
1138 // and use their variant (such as wmemchr, etc.). The problem
1139 // is that these functions are quite rare, even though they are
1140 // part of the current POSIX standard. In addition, most compilers
1141 // (including even MSC) inline them just like we do right in their
1142 // headers.
1143 //
1144 #if wxUSE_UNICODE
1145 #include <string.h> //for mem funcs
1146
1147 //implement our own wmem variants
1148 inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
1149 {
1150 for(;l && *s != c;--l, ++s) {}
1151
1152 if(l)
1153 return (wxChar*)s;
1154 return NULL;
1155 }
1156
1157 inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
1158 {
1159 for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
1160
1161 if(len)
1162 return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
1163 else
1164 return 0;
1165 }
1166
1167 inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
1168 {
1169 return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
1170 }
1171
1172 inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
1173 {
1174 return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
1175 }
1176
1177 inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len)
1178 {
1179 wxChar* szRet = szOut;
1180
1181 while (len--)
1182 *szOut++ = cIn;
1183
1184 return szRet;
1185 }
1186
1187 #else //!wxUSE_UNICODE
1188 # define wxTmemchr memchr
1189 # define wxTmemcmp memcmp
1190 # define wxTmemcpy memcpy
1191 # define wxTmemmove memmove
1192 # define wxTmemset memset
1193 #endif
1194
1195 #endif /*__cplusplus*/
1196
1197
1198 #endif /* _WX_WXCHAR_H_ */
1199