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