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