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