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