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