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