]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wxchar.h
Committing in .
[wxWidgets.git] / include / wx / wxchar.h
CommitLineData
e35d0039
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wxchar.h
3// Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4// Author: Joel Farley
5// Modified by:
6// Created: 1998/06/12
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows copyright
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WXCHAR_H_
13#define _WX_WXCHAR_H_
14
88ac883a
VZ
15//#ifdef __GNUG__
16//#pragma interface "wxchar.h"
17//#endif
e35d0039
JS
18
19// only do SBCS or _UNICODE
20#if defined (_MBCS )
1777b9bb 21# error "MBCS is not supported by wxChar"
e35d0039
JS
22#endif
23
853d7d3d
OK
24// set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined
25#if defined(_UNICODE) || defined(UNICODE)
1777b9bb
DW
26# undef wxUSE_UNICODE
27# define wxUSE_UNICODE 1
853d7d3d 28#else
1777b9bb
DW
29# ifndef wxUSE_UNICODE
30# define wxUSE_UNICODE 0
31# endif
853d7d3d
OK
32#endif
33
34// and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1...
35#if wxUSE_UNICODE
1777b9bb
DW
36# ifndef _UNICODE
37# define _UNICODE
38# endif
39# ifndef UNICODE
40# define UNICODE
41# endif
853d7d3d
OK
42#endif
43
34f9227c 44// Windows (VC++) has broad TCHAR support
3f4a0c5b 45#if defined(__VISUALC__) && defined(__WIN32__)
e35d0039 46
1777b9bb 47# define HAVE_WCSLEN 1
a23fd0e1 48
1777b9bb 49# include <tchar.h>
73974df1 50
1777b9bb 51# if wxUSE_UNICODE // temporary - preserve binary compatibility
e35d0039 52typedef _TCHAR wxChar;
3f4a0c5b 53typedef _TSCHAR wxSChar;
e35d0039 54typedef _TUCHAR wxUChar;
1777b9bb
DW
55# else
56# define wxChar char
57# define wxSChar signed char
58# define wxUChar unsigned char
59# endif
81d425f6 60 // wchar_t is available
1777b9bb
DW
61# undef wxUSE_WCHAR_T
62# define wxUSE_WCHAR_T 1
e35d0039
JS
63
64 // ctype.h functions
1777b9bb
DW
65# define wxIsalnum _istalnum
66# define wxIsalpha _istalpha
67# define wxIsctrl _istctrl
68# define wxIsdigit _istdigit
69# define wxIsgraph _istgraph
70# define wxIslower _istlower
71# define wxIsprint _istprint
72# define wxIspunct _istpunct
73# define wxIsspace _istspace
74# define wxIsupper _istupper
75# define wxIsxdigit _istxdigit
76# define wxTolower _totlower
77# define wxToupper _totupper
e35d0039
JS
78
79 // locale.h functons
1777b9bb 80# define wxSetlocale _tsetlocale
e35d0039
JS
81
82 // string.h functions
1777b9bb
DW
83# define wxStrcat _tcscat
84# define wxStrchr _tcschr
85# define wxStrcmp _tcscmp
86# define wxStrcoll _tcscoll
87# define wxStrcpy _tcscpy
88# define wxStrcspn _tcscspn
89# define wxStrftime _tcsftime
90# define wxStricmp _tcsicmp
91# define wxStrlen_ _tcslen // used in wxStrlen inline function
92# define wxStrncat _tcsncat
93# define wxStrncmp _tcsncmp
94# define wxStrncpy _tcsncpy
95# define wxStrpbrk _tcspbrk
96# define wxStrrchr _tcsrchr
97# define wxStrspn _tcsspn
98# define wxStrstr _tcsstr
99# define wxStrtod _tcstod
e97a90f0 100// is there a _tcstok[_r] ?
1777b9bb
DW
101# define wxStrtol _tcstol
102# define wxStrtoul _tcstoul
103# define wxStrxfrm _tcsxfrm
e35d0039
JS
104
105 // stdio.h functions
1777b9bb
DW
106# define wxFgetc _fgettc
107# define wxFgetchar _fgettchar
108# define wxFgets _fgetts
109# define wxFopen _tfopen
110# define wxFputc _fputtc
111# define wxFputchar _fputtchar
112# define wxFprintf _ftprintf
113# define wxFreopen _tfreopen
114# define wxFscanf _ftscanf
115# define wxGetc _gettc
116# define wxGetchar _gettchar
117# define wxGets _getts
118# define wxPerror _tperror
119# define wxPrintf _tprintf
120# define wxPutc _puttc
121# define wxPutchar _puttchar
122# define wxPuts _putts
123# define wxRemove _tremove
124# define wxRename _trename
125# define wxScanf _tscanf
126# define wxSprintf _stprintf
127# define wxSscanf _stscanf
128# define wxTmpnam _ttmpnam
129# define wxUngetc _tungetc
130# define wxVfprint _vftprintf
131# define wxVprintf _vtprintf
132# define wxVsscanf _vstscanf
133# define wxVsprintf _vstprintf
e35d0039
JS
134
135 // stdlib.h functions
1777b9bb
DW
136# if !wxUSE_UNICODE
137# define wxAtof atof
138# endif
139# define wxAtoi _ttoi
140# define wxAtol _ttol
141# define wxGetenv _tgetenv
142# define wxSystem _tsystem
e35d0039
JS
143
144 // time.h functions
1777b9bb
DW
145# define wxAsctime _tasctime
146# define wxCtime _tctime
e35d0039
JS
147
148// #elif defined(XXX)
149 // #include XXX-specific files here
150 // typeddef YYY wxChar;
151
152 // translate wxZZZ names
153
853d7d3d 154#elif defined(__BORLANDC__) && defined(__WIN32__)
c7173739
VZ
155#if (__BORLANDC__ >= 0x520)
156// BC++ 5.02 and later has broad tchar support
157# define HAVE_WCSLEN 1
158
159# include <tchar.h>
160
161# if wxUSE_UNICODE // temporary - preserve binary compatibility
162typedef _TCHAR wxChar;
163typedef _TSCHAR wxSChar;
164typedef _TUCHAR wxUChar;
165# else
166# define wxChar char
167# define wxSChar signed char
168# define wxUChar unsigned char
169# endif
170 // wchar_t is available
171# undef wxUSE_WCHAR_T
172# define wxUSE_WCHAR_T 1
173
174 // ctype.h functions
175# define wxIsalnum _istalnum
176# define wxIsalpha _istalpha
177# define wxIsctrl _istcntrl
178# define wxIsdigit _istdigit
179# define wxIsgraph _istgraph
180# define wxIslower _istlower
181# define wxIsprint _istprint
182# define wxIspunct _istpunct
183# define wxIsspace _istspace
184# define wxIsupper _istupper
185# define wxIsxdigit _istxdigit
186# define wxTolower _totlower
187# define wxToupper _totupper
188
189 // locale.h functons
190# define wxSetlocale _tsetlocale
191
192 // string.h functions
193# define wxStrcat _tcscat
194# define wxStrchr _tcschr
195# define wxStrcmp _tcscmp
196# define wxStrcoll _tcscoll
197# define wxStrcpy _tcscpy
198# define wxStrcspn _tcscspn
199# define wxStrftime _tcsftime
200# define wxStricmp _tcsicmp
201# define wxStrlen_ _tcslen // used in wxStrlen inline function
202# define wxStrncat _tcsncat
203# define wxStrncmp _tcsncmp
204# define wxStrncpy _tcsncpy
205# define wxStrpbrk _tcspbrk
206# define wxStrrchr _tcsrchr
207# define wxStrspn _tcsspn
208# define wxStrstr _tcsstr
209# define wxStrtod _tcstod
210// is there a _tcstok[_r] ?
211# define wxStrtol _tcstol
212# define wxStrtoul _tcstoul
213# define wxStrxfrm _tcsxfrm
853d7d3d 214
c7173739
VZ
215 // stdio.h functions
216# define wxFgetc _fgettc
217# define wxFgetchar _fgettchar
218# define wxFgets _fgetts
219# define wxFopen _tfopen
220# define wxFputc _fputtc
221# define wxFputchar _fputtchar
222# define wxFprintf _ftprintf
223# define wxFreopen _tfreopen
224# define wxFscanf _ftscanf
225# define wxGetc _gettc
226# define wxGetchar _gettchar
227# define wxGets _getts
228# define wxPerror _tperror
229# define wxPrintf _tprintf
230# define wxPutc _puttc
231# define wxPutchar _puttchar
232# define wxPuts _putts
233# define wxRemove _tremove
234# define wxRename _trename
235# define wxScanf _tscanf
236# define wxSprintf _stprintf
237# define wxSscanf _stscanf
238# define wxTmpnam _ttmpnam
239# define wxUngetc _ungettc
240# define wxVfprint _vftprintf
241# define wxVprintf _vtprintf
242# define wxVsscanf _vstscanf
243# define wxVsprintf _vstprintf
244
245 // stdlib.h functions
246# define wxAtof _ttof
247# define wxAtoi _ttoi
248# define wxAtol _ttol
249# define wxGetenv _tgetenv
250# define wxSystem _tsystem
251
252 // time.h functions
253# define wxAsctime _tasctime
254# define wxCtime _tctime
255
256// #elif defined(XXX)
257 // #include XXX-specific files here
258 // typeddef YYY wxChar;
259
260 // translate wxZZZ names
261
262#else
853d7d3d
OK
263// Borland C++ 4.52 doesn't have much tchar support
264// maybe Borland C++ 5.02 has, can't check right now
265// but I'll use the Win32 API instead here
266
1777b9bb
DW
267# include <tchar.h>
268# if wxUSE_UNICODE // temporary - preserve binary compatibility
853d7d3d
OK
269typedef _TCHAR wxChar;
270typedef _TSCHAR wxSChar;
271typedef _TUCHAR wxUChar;
1777b9bb
DW
272# else
273# define wxChar char
274# define wxSChar signed char
275# define wxUChar unsigned char
276# endif
81d425f6 277 // wchar_t is available
1777b9bb 278# undef wxUSE_WCHAR_T
cf1d22d6 279// This test is for C++Builder
1777b9bb 280# define wxUSE_WCHAR_T 1
cf1d22d6 281# define wxNEED_WCSLEN
1777b9bb 282# define wxNEED_WX_CTYPE_H
853d7d3d 283// #define wxStrtok strtok_r // Borland C++ 4.52 doesn't have strtok_r
1777b9bb
DW
284# define wxNEED_WX_STRING_H
285# define wxNEED_WX_STDIO_H
286# define wxNEED_WX_STDLIB_H
287# define wxNEED_WX_TIME_H
853d7d3d 288
c7173739
VZ
289#endif // __BORLANDC__ >= 0x530
290
ec6f6982 291// VisualAge C++ V4.0 has broad tchar support
d5c22d10 292#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400
ec6f6982
DW
293
294# define HAVE_WCSLEN 1
d5c22d10 295# include <wchar.h>
ec6f6982
DW
296# include <tchar.h>
297
298# if wxUSE_UNICODE // temporary - preserve binary compatibility
299typedef _TCHAR wxChar;
300typedef _TSCHAR wxSChar;
301typedef _TUCHAR wxUChar;
302# else
303# define wxChar char
304# define wxSChar signed char
305# define wxUChar unsigned char
306# endif
307 // wchar_t is available
308# undef wxUSE_WCHAR_T
309# define wxUSE_WCHAR_T 1
310
311 // ctype.h functions
312# define wxIsalnum _istalnum
313# define wxIsalpha _istalpha
d5c22d10 314# define wxIsctrl _istcntrl
ec6f6982
DW
315# define wxIsdigit _istdigit
316# define wxIsgraph _istgraph
317# define wxIslower _istlower
318# define wxIsprint _istprint
319# define wxIspunct _istpunct
320# define wxIsspace _istspace
321# define wxIsupper _istupper
322# define wxIsxdigit _istxdigit
323# define wxTolower _totlower
324# define wxToupper _totupper
325
d5c22d10
DW
326 // locale.h functons -- not defined in tchar.h
327# define wxSetlocale setlocale
ec6f6982
DW
328
329 // string.h functions
330# define wxStrcat _tcscat
331# define wxStrchr _tcschr
332# define wxStrcmp _tcscmp
333# define wxStrcoll _tcscoll
334# define wxStrcpy _tcscpy
335# define wxStrcspn _tcscspn
336# define wxStrftime _tcsftime
337# define wxStricmp _tcsicmp
338# define wxStrlen_ _tcslen // used in wxStrlen inline function
339# define wxStrncat _tcsncat
340# define wxStrncmp _tcsncmp
341# define wxStrncpy _tcsncpy
342# define wxStrpbrk _tcspbrk
343# define wxStrrchr _tcsrchr
344# define wxStrspn _tcsspn
345# define wxStrstr _tcsstr
346# define wxStrtod _tcstod
347// is there a _tcstok[_r] ?
348# define wxStrtol _tcstol
349# define wxStrtoul _tcstoul
350# define wxStrxfrm _tcsxfrm
351
352 // stdio.h functions
353# define wxFgetc _fgettc
ec6f6982 354# define wxFgets _fgetts
ec6f6982 355# define wxFputc _fputtc
ec6f6982 356# define wxFprintf _ftprintf
ec6f6982
DW
357# define wxFscanf _ftscanf
358# define wxGetc _gettc
359# define wxGetchar _gettchar
ec6f6982
DW
360# define wxPrintf _tprintf
361# define wxPutc _puttc
362# define wxPutchar _puttchar
ec6f6982
DW
363# define wxScanf _tscanf
364# define wxSprintf _stprintf
365# define wxSscanf _stscanf
ec6f6982
DW
366# define wxVfprint _vftprintf
367# define wxVprintf _vtprintf
ec6f6982 368# define wxVsprintf _vstprintf
d5c22d10
DW
369// not defined in tchar.h
370# define wxFgetchar fgetchar
371# define wxFopen fopen
372# define wxFputchar fputchar
373# define wxFreopen freopen
374# define wxGets gets
375# define wxPerror perror
376# define wxPuts puts
377# define wxRemove remove
378# define wxRename rename
379# define wxTmpnam tmpnam
380# define wxUngetc ungetc
381# define wxVsscanf vsscanf
ec6f6982 382
d5c22d10 383 // stdlib.h functions -- none defined in tchar.h
ec6f6982
DW
384# if !wxUSE_UNICODE
385# define wxAtof atof
386# endif
d5c22d10
DW
387# define wxAtoi atoi
388# define wxAtol atol
389# define wxGetenv getenv
390# define wxSystem system
ec6f6982 391
d5c22d10
DW
392 // time.h functions -- none defined in tchar.h
393# define wxAsctime asctime
394# define wxCtime ctime
ec6f6982
DW
395
396// #elif defined(XXX)
397 // #include XXX-specific files here
398 // typeddef YYY wxChar;
399
400 // translate wxZZZ names
401
81d425f6 402#else//!TCHAR-aware compilers
34f9227c 403
81d425f6 404// check whether we should include wchar.h or equivalent
1777b9bb
DW
405# if wxUSE_UNICODE
406# undef wxUSE_WCHAR_T
407# define wxUSE_WCHAR_T 1 // wchar_t *must* be available in Unicode mode
408# elif !defined(wxUSE_WCHAR_T)
409# if defined(__VISUALC__) && (__VISUALC__ < 900)
410# define wxUSE_WCHAR_T 0 // wchar_t is not available for MSVC++ 1.5
411# elif defined(__UNIX__)
412# if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__)
413# define wxUSE_WCHAR_T 1
414# else
415# define wxUSE_WCHAR_T 0
416# endif
417# elif defined(__GNUWIN32__) && !defined(__MINGW32__) // Cygwin (not Mingw32) doesn't have wcslen.h, needed in buffer.h
418# define wxUSE_WCHAR_T 0
419# elif defined(__BORLANDC__) // WIN16 BC++
420# define wxUSE_WCHAR_T 0
421# elif defined(__WATCOMC__)
422# define wxUSE_WCHAR_T 0
423# else
a89ae1e4 424 // add additional compiler checks if this fails
1777b9bb
DW
425# define wxUSE_WCHAR_T 1
426# endif
427# endif//wxUSE_UNICODE
428
429# if wxUSE_WCHAR_T
430# ifdef HAVE_WCSTR_H
431# include <wcstr.h>
432# else
433# ifndef __FreeBSD__
434# include <wchar.h>
435# else
436# include <stdlib.h>
437# define wxNEED_WCSLEN
438# endif
439# endif
440# endif
65d77246 441
34f9227c 442// check whether we are doing Unicode
1777b9bb 443# if wxUSE_UNICODE
34f9227c 444
1777b9bb 445# include <wctype.h>
34f9227c
OK
446
447// this is probably glibc-specific
1777b9bb 448# if defined(__WCHAR_TYPE__)
34f9227c
OK
449
450typedef __WCHAR_TYPE__ wxChar;
451typedef signed __WCHAR_TYPE__ wxSChar;
452typedef unsigned __WCHAR_TYPE__ wxUChar;
453
cdb51680 454# define _T(x) L##x
1777b9bb
DW
455
456 // ctype.h functions (wctype.h)
457# define wxIsalnum iswalnum
458# define wxIsalpha iswalpha
459# define wxIsctrl iswcntrl
460# define wxIsdigit iswdigit
461# define wxIsgraph iswgraph
462# define wxIslower iswlower
463# define wxIsprint iswprint
464# define wxIspunct iswpunct
465# define wxIsspace iswspace
466# define wxIsupper iswupper
467# define wxIsxdigit iswxdigit
468
469# if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
470 // /usr/include/wctype.h incorrectly declares translations tables which
471 // provokes tons of compile-time warnings - try 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
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_ wcslen // used in wxStrlen inline function
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 wxStrtok wcstok
496# define wxStrtol wcstol
497# define wxStrtoul wcstoul
498# define wxStrxfrm wcsxfrm
e35d0039 499
34f9227c 500// glibc doesn't have wc equivalents of the other stuff
1777b9bb
DW
501# define wxNEED_WX_STDIO_H
502# define wxNEED_WX_STDLIB_H
503# define wxNEED_WX_TIME_H
34f9227c 504
1777b9bb
DW
505# else//!glibc
506# error "Please define your compiler's Unicode conventions in wxChar.h"
507# endif
508# else//!Unicode
e35d0039 509
1777b9bb
DW
510# include <ctype.h>
511# include <string.h>
e97a90f0 512
e90c1d2a
VZ
513# if 0 // temporary - preserve binary compatibilty
514 typedef char wxChar;
515 typedef signed char wxSChar;
516 typedef unsigned char wxUChar;
517# else
518# define wxChar char
519# define wxSChar signed char
520# define wxUChar unsigned char
521# endif
522
523# ifdef __FreeBSD__
cdb51680 524# undef _T
e90c1d2a 525# endif
b4fe5125
JS
526
527# if !defined(__MINGW32__) || !defined(_T)
528# define _T(x) x
529# endif
1777b9bb
DW
530
531 // ctype.h functions
e90c1d2a
VZ
532# define wxIsalnum isalnum
533# define wxIsalpha isalpha
534# define wxIsctrl isctrl
535# define wxIsdigit isdigit
536# define wxIsgraph isgraph
537# define wxIslower islower
538# define wxIsprint isprint
539# define wxIspunct ispunct
540# define wxIsspace isspace
541# define wxIsupper isupper
542# define wxIsxdigit isxdigit
543# define wxTolower tolower
544# define wxToupper toupper
545
546 // locale.h functons
547# define wxSetlocale setlocale
548
549 // string.h functions
550 // #define wxStricmp strcasecmp
551 // wxStricmp is defined below!!
552
553 #ifdef HAVE_STRTOK_R
554 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
555 #else
556 #define wxStrtok(str, sep, last) strtok(str, sep)
557 #endif
1777b9bb
DW
558
559 // leave the rest to defaults below
e90c1d2a
VZ
560# define wxNEED_WX_STRING_H
561# define wxNEED_WX_STDIO_H
562# define wxNEED_WX_STDLIB_H
563# define wxNEED_WX_TIME_H
1777b9bb
DW
564
565# endif//Unicode
853d7d3d
OK
566#endif//TCHAR-aware compilers
567
568// define wxStricmp for various compilers without Unicode possibilities
569#if !defined(wxStricmp) && !wxUSE_UNICODE
fd9811b1 570# if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__SALFORDC__) || defined(__VISAGECPP__) || defined(__EMX__)
1777b9bb 571# define wxStricmp stricmp
9199e66f 572# define wxStrnicmp strnicmp
585ae8cb 573# elif defined(__SC__) || defined(__VISUALC__) || (defined(__MWERKS__) && defined(__INTEL__))
1777b9bb 574# define wxStricmp _stricmp
9199e66f 575# define wxStrnicmp _strnicmp
1777b9bb
DW
576# elif defined(__UNIX__) || defined(__GNUWIN32__)
577# define wxStricmp strcasecmp
9199e66f 578# define wxStrnicmp strncasecmp
1777b9bb
DW
579# elif defined(__MWERKS__) && !defined(__INTEL__)
580 // use wxWindows' implementation
581# else
582 // if you leave wxStricmp undefined, wxWindows' implementation will be used
583# error "Please define string case-insensitive compare for your OS/compiler"
584# endif
853d7d3d
OK
585#endif
586
587// if we need to define for standard headers, and we're not using Unicode,
588// just define to standard C library routines
589#if !wxUSE_UNICODE
1777b9bb
DW
590# ifdef wxNEED_WX_STRING_H
591# define wxStrcat strcat
592# define wxStrchr strchr
593# define wxStrcmp strcmp
594# define wxStrcoll strcoll
595# define wxStrcpy strcpy
596# define wxStrcspn strcspn
597# define wxStrdup strdup
598# define wxStrlen_ strlen // used in wxStrlen inline function
599# define wxStrncat strncat
600# define wxStrncmp strncmp
601# define wxStrncpy strncpy
602# define wxStrpbrk strpbrk
603# define wxStrrchr strrchr
604# define wxStrspn strspn
605# define wxStrstr strstr
606# define wxStrtod strtod
607# define wxStrtol strtol
608# define wxStrtoul strtoul
609# define wxStrxfrm strxfrm
610# undef wxNEED_WX_STRING_H
611# endif
612
613# ifdef wxNEED_WX_STDIO_H
614# define wxFgetc fgetc
615# define wxFgetchar fgetchar
616# define wxFgets fgets
617# define wxFopen fopen
618# define wxFputc fputc
619# define wxFputchar fputchar
620# define wxFprintf fprintf
621# define wxFreopen freopen
622# define wxFscanf fscanf
623# define wxGetc getc
624# define wxGetchar getchar
625# define wxGets gets
626# define wxPerror perror
627# define wxPrintf printf
628# define wxPutc putc
629# define wxPutchar putchar
630# define wxPuts puts
631# define wxRemove remove
632# define wxRename rename
633# define wxScanf scanf
634# define wxSprintf sprintf
635# define wxSscanf sscanf
636# define wxTmpnam tmpnam
637# define wxUngetc ungetc
638# define wxVfprint vfprintf
639# define wxVprintf vprintf
640# define wxVsscanf vsscanf
641# define wxVsprintf vsprintf
642# undef wxNEED_WX_STDIO_H
643# endif
644
645# ifdef wxNEED_WX_STDLIB_H
646# define wxAtof atof
647# define wxAtoi atoi
648# define wxAtol atol
649# define wxGetenv getenv
650# define wxSystem system
651# undef wxNEED_WX_STDLIB_H
652# endif
653
654# ifdef wxNEED_WX_TIME_H
655# define wxAsctime asctime
656# define wxCtime ctime
657# define wxStrftime strftime
658# undef wxNEED_WX_TIME_H
659# endif
853d7d3d 660#endif //!Unicode
e35d0039 661
853d7d3d 662#if defined(wxNEED_WCSLEN) && wxUSE_UNICODE
1777b9bb
DW
663# define wcslen wxStrlen
664# undef wxNEED_WCSLEN
853d7d3d 665#endif
e35d0039
JS
666
667/// checks whether the passed in pointer is NULL and if the string is empty
49828363 668WXDLLEXPORT inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
e35d0039 669
853d7d3d 670#ifndef wxNEED_WX_STRING_H
e35d0039 671/// safe version of strlen() (returns 0 if passed NULL pointer)
49828363 672WXDLLEXPORT inline size_t wxStrlen(const wxChar *psz)
853d7d3d 673 { return psz ? wxStrlen_(psz) : 0; }
34f9227c 674#endif
e35d0039 675
81d425f6 676#if wxUSE_WCHAR_T
e97a90f0 677// multibyte<->widechar conversion
49828363
RD
678WXDLLEXPORT size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
679WXDLLEXPORT size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1777b9bb
DW
680# if wxUSE_UNICODE
681# define wxMB2WX wxMB2WC
682# define wxWX2MB wxWC2MB
683# define wxWC2WX wxStrncpy
684# define wxWX2WC wxStrncpy
685# else
686# define wxMB2WX wxStrncpy
687# define wxWX2MB wxStrncpy
688# define wxWC2WX wxWC2MB
689# define wxWX2WC wxMB2WC
690# endif
0f3e3e0c
JS
691#else
692// No wxUSE_WCHAR_T: we have to do something (JACS)
1777b9bb
DW
693# define wxMB2WC wxStrncpy
694# define wxWC2MB wxStrncpy
695# define wxMB2WX wxStrncpy
696# define wxWX2MB wxStrncpy
697# define wxWC2WX wxWC2MB
698# define wxWX2WC wxMB2WC
81d425f6 699#endif
0f3e3e0c 700
49828363 701WXDLLEXPORT bool wxOKlibc(); // for internal use
e97a90f0
OK
702
703// if libc versions are not available, use replacements defined in wxchar.cpp
704#ifndef wxStrdup
49828363 705WXDLLEXPORT wxChar * wxStrdup(const wxChar *psz);
e97a90f0
OK
706#endif
707
0841bffa 708#ifndef wxStricmp
49828363 709WXDLLEXPORT int wxStricmp(const wxChar *psz1, const wxChar *psz2);
0841bffa
OK
710#endif
711
e97a90f0 712#ifndef wxStrtok
49828363 713WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
e97a90f0
OK
714#endif
715
716#ifndef wxSetlocale
49828363 717WXDLLEXPORT wxChar * wxSetlocale(int category, const wxChar *locale);
e97a90f0
OK
718#endif
719
853d7d3d 720#ifdef wxNEED_WCSLEN // for use in buffer.h
49828363 721WXDLLEXPORT size_t wcslen(const wchar_t *s);
853d7d3d
OK
722#endif
723
57f6da0d 724#ifdef wxNEED_WX_CTYPE_H
49828363
RD
725WXDLLEXPORT int wxIsalnum(wxChar ch);
726WXDLLEXPORT int wxIsalpha(wxChar ch);
727WXDLLEXPORT int wxIsctrl(wxChar ch);
728WXDLLEXPORT int wxIsdigit(wxChar ch);
729WXDLLEXPORT int wxIsgraph(wxChar ch);
730WXDLLEXPORT int wxIslower(wxChar ch);
731WXDLLEXPORT int wxIsprint(wxChar ch);
732WXDLLEXPORT int wxIspunct(wxChar ch);
733WXDLLEXPORT int wxIsspace(wxChar ch);
734WXDLLEXPORT int wxIsupper(wxChar ch);
735WXDLLEXPORT int wxIsxdigit(wxChar ch);
736WXDLLEXPORT int wxTolower(wxChar ch);
737WXDLLEXPORT int wxToupper(wxChar ch);
57f6da0d
OK
738#endif
739
853d7d3d 740#ifdef wxNEED_WX_STRING_H
49828363
RD
741WXDLLEXPORT wxChar * wxStrcat(wxChar *dest, const wxChar *src);
742WXDLLEXPORT wxChar * wxStrchr(const wxChar *s, wxChar c);
743WXDLLEXPORT int wxStrcmp(const wxChar *s1, const wxChar *s2);
744WXDLLEXPORT int wxStrcoll(const wxChar *s1, const wxChar *s2);
745WXDLLEXPORT wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
746WXDLLEXPORT size_t wxStrcspn(const wxChar *s, const wxChar *reject);
747WXDLLEXPORT size_t wxStrlen(const wxChar *s);
748WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
749WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
750WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
751WXDLLEXPORT wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
752WXDLLEXPORT wxChar * wxStrrchr(const wxChar *s, wxChar c);
753WXDLLEXPORT size_t wxStrspn(const wxChar *s, const wxChar *accept);
754WXDLLEXPORT wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
755WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr);
756WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
757WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
758WXDLLEXPORT size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
853d7d3d
OK
759#endif
760
e97a90f0 761#ifdef wxNEED_WX_STDIO_H
1777b9bb
DW
762# include <stdio.h>
763# include <stdarg.h>
e385b3ff
OK
764WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode);
765WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
49828363
RD
766WXDLLEXPORT int wxPrintf(const wxChar *fmt, ...);
767WXDLLEXPORT int wxVprintf(const wxChar *fmt, va_list argptr);
768WXDLLEXPORT int wxFprintf(FILE *stream, const wxChar *fmt, ...);
769WXDLLEXPORT int wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr);
770WXDLLEXPORT int wxSprintf(wxChar *buf, const wxChar *fmt, ...);
771WXDLLEXPORT int wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr);
772WXDLLEXPORT int wxSscanf(const wxChar *buf, const wxChar *fmt, ...);
773WXDLLEXPORT int wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr);
e97a90f0
OK
774#endif
775
a982ddd2 776#ifndef wxAtof
49828363 777WXDLLEXPORT double wxAtof(const wxChar *psz);
a982ddd2
OK
778#endif
779
780#ifdef wxNEED_WX_STDLIB_H
49828363
RD
781WXDLLEXPORT int wxAtoi(const wxChar *psz);
782WXDLLEXPORT long wxAtol(const wxChar *psz);
783WXDLLEXPORT wxChar * wxGetenv(const wxChar *name);
784WXDLLEXPORT int wxSystem(const wxChar *psz);
639a9fb5
OK
785#endif
786
e385b3ff
OK
787#ifdef wxNEED_WX_TIME_H
788WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm);
789#endif
790
cdb51680
VZ
791// although global macros with such names are really bad, we want to have
792// another name for _T() which should be used to avoid confusion between _T()
793// and _() in wxWindows sources
223d09f6 794#define wxT(x) _T(x)
cdb51680 795
e90c1d2a
VZ
796// a Unicode-friendly __FILE__ analog
797#ifndef __TFILE__
223d09f6 798 #define __XFILE__(x) wxT(x)
e90c1d2a
VZ
799 #define __TFILE__ __XFILE__(__FILE__)
800#endif
801
e35d0039
JS
802#endif
803 //_WX_WXCHAR_H_
1777b9bb 804