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