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