]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/wxchar.h
c7a3dbdc6f2de65b564a5f5976196482854b70c1
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Declarations common to wx char/wchar_t usage (wide chars)
8 // Copyright: (c) wxWindows copyright
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "wxchar.h"
19 // only do SBCS or _UNICODE
21 #error "MBCS is not supported by wxChar"
24 // set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined
25 #if defined(_UNICODE) || defined(UNICODE)
27 #define wxUSE_UNICODE 1
30 #define wxUSE_UNICODE 0
34 // and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1...
44 // Windows (VC++) has broad TCHAR support
45 #if defined(__VISUALC__) && defined(__WIN32__)
48 #if wxUSE_UNICODE // temporary - preserve binary compatibility
49 typedef _TCHAR wxChar
;
50 typedef _TSCHAR wxSChar
;
51 typedef _TUCHAR wxUChar
;
54 #define wxSChar signed char
55 #define wxUChar unsigned char
57 // wchar_t is available
59 #define wxUSE_WCHAR_T 1
62 #define wxIsalnum _istalnum
63 #define wxIsalpha _istalpha
64 #define wxIsctrl _istctrl
65 #define wxIsdigit _istdigit
66 #define wxIsgraph _istgraph
67 #define wxIslower _istlower
68 #define wxIsprint _istprint
69 #define wxIspunct _istpunct
70 #define wxIsspace _istspace
71 #define wxIsupper _istupper
72 #define wxIsxdigit _istxdigit
73 #define wxTolower _totlower
74 #define wxToupper _totupper
77 #define wxSetlocale _tsetlocale
80 #define wxStrcat _tcscat
81 #define wxStrchr _tcschr
82 #define wxStrcmp _tcscmp
83 #define wxStrcoll _tcscoll
84 #define wxStrcpy _tcscpy
85 #define wxStrcspn _tcscspn
86 #define wxStrftime _tcsftime
87 #define wxStricmp _tcsicmp
88 #define wxStrlen_ _tcslen // used in wxStrlen inline function
89 #define wxStrncat _tcsncat
90 #define wxStrncmp _tcsncmp
91 #define wxStrncpy _tcsncpy
92 #define wxStrpbrk _tcspbrk
93 #define wxStrrchr _tcsrchr
94 #define wxStrspn _tcsspn
95 #define wxStrstr _tcsstr
96 #define wxStrtod _tcstod
97 // is there a _tcstok[_r] ?
98 #define wxStrtol _tcstol
99 #define wxStrtoul _tcstoul
100 #define wxStrxfrm _tcsxfrm
103 #define wxFgetc _fgettc
104 #define wxFgetchar _fgettchar
105 #define wxFgets _fgetts
106 #define wxFopen _tfopen
107 #define wxFputc _fputtc
108 #define wxFputchar _fputtchar
109 #define wxFprintf _ftprintf
110 #define wxFreopen _tfreopen
111 #define wxFscanf _ftscanf
112 #define wxGetc _gettc
113 #define wxGetchar _gettchar
114 #define wxGets _getts
115 #define wxPerror _tperror
116 #define wxPrintf _tprintf
117 #define wxPutc _puttc
118 #define wxPutchar _puttchar
119 #define wxPuts _putts
120 #define wxRemove _tremove
121 #define wxRename _trename
122 #define wxScanf _tscanf
123 #define wxSprintf _stprintf
124 #define wxSscanf _stscanf
125 #define wxTmpnam _ttmpnam
126 #define wxUngetc _tungetc
127 #define wxVfprint _vftprintf
128 #define wxVprintf _vtprintf
129 #define wxVsscanf _vstscanf
130 #define wxVsprintf _vstprintf
132 // stdlib.h functions
138 #define wxGetenv _tgetenv
139 #define wxSystem _tsystem
142 #define wxAsctime _tasctime
143 #define wxCtime _tctime
145 // #elif defined(XXX)
146 // #include XXX-specific files here
147 // typeddef YYY wxChar;
149 // translate wxZZZ names
151 #elif defined(__BORLANDC__) && defined(__WIN32__)
153 // Borland C++ 4.52 doesn't have much tchar support
154 // maybe Borland C++ 5.02 has, can't check right now
155 // but I'll use the Win32 API instead here
158 #if wxUSE_UNICODE // temporary - preserve binary compatibility
159 typedef _TCHAR wxChar
;
160 typedef _TSCHAR wxSChar
;
161 typedef _TUCHAR wxUChar
;
164 #define wxSChar signed char
165 #define wxUChar unsigned char
167 // wchar_t is available
169 #define wxUSE_WCHAR_T 1
171 #define wxNEED_WX_CTYPE_H
172 // #define wxStrtok strtok_r // Borland C++ 4.52 doesn't have strtok_r
173 #define wxNEED_WX_STRING_H
174 #define wxNEED_WX_STDIO_H
175 #define wxNEED_WX_STDLIB_H
176 #define wxNEED_WX_TIME_H
177 #define wxNEED_WCSLEN
179 #else//!TCHAR-aware compilers
181 // check whether we should include wchar.h or equivalent
184 #define wxUSE_WCHAR_T 1 // wchar_t *must* be available in Unicode mode
185 #elif !defined(wxUSE_WCHAR_T)
186 #if defined(__VISUALC__) && (__VISUALC__ < 900)
187 #define wxUSE_WCHAR_T 0 // wchar_t is not available for MSVC++ 1.5
188 #elif defined(__UNIX__)
189 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H)
190 #define wxUSE_WCHAR_T 1
192 #define wxUSE_WCHAR_T 0
194 #elif defined(__GNUWIN32__) && !defined(__MINGW32__) // Cygwin (not Mingw32) doesn't have wcslen.h, needed in buffer.h
195 #define wxUSE_WCHAR_T 0
197 // add additional compiler checks if this fails
198 #define wxUSE_WCHAR_T 1
200 #endif//wxUSE_UNICODE
210 // check whether we are doing Unicode
215 // this is probably glibc-specific
216 #if defined(__WCHAR_TYPE__)
218 typedef __WCHAR_TYPE__ wxChar
;
219 typedef signed __WCHAR_TYPE__ wxSChar
;
220 typedef unsigned __WCHAR_TYPE__ wxUChar
;
224 // ctype.h functions (wctype.h)
225 #define wxIsalnum iswalnum
226 #define wxIsalpha iswalpha
227 #define wxIsctrl iswcntrl
228 #define wxIsdigit iswdigit
229 #define wxIsgraph iswgraph
230 #define wxIslower iswlower
231 #define wxIsprint iswprint
232 #define wxIspunct iswpunct
233 #define wxIsspace iswspace
234 #define wxIsupper iswupper
235 #define wxIsxdigit iswxdigit
237 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
238 // /usr/include/wctype.h incorrectly declares translations tables which
239 // provokes tons of compile-time warnings - try to correct this
240 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
241 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
243 #define wxTolower towlower
244 #define wxToupper towupper
247 // string.h functions (wchar.h)
248 #define wxStrcat wcscat
249 #define wxStrchr wcschr
250 #define wxStrcmp wcscmp
251 #define wxStrcoll wcscoll
252 #define wxStrcpy wcscpy
253 #define wxStrcspn wcscspn
254 #define wxStrlen_ wcslen // used in wxStrlen inline function
255 #define wxStrncat wcsncat
256 #define wxStrncmp wcsncmp
257 #define wxStrncpy wcsncpy
258 #define wxStrpbrk wcspbrk
259 #define wxStrrchr wcsrchr
260 #define wxStrspn wcsspn
261 #define wxStrstr wcsstr
262 #define wxStrtod wcstod
263 #define wxStrtok wcstok
264 #define wxStrtol wcstol
265 #define wxStrtoul wcstoul
266 #define wxStrxfrm wcsxfrm
268 // glibc doesn't have wc equivalents of the other stuff
269 #define wxNEED_WX_STDIO_H
270 #define wxNEED_WX_STDLIB_H
271 #define wxNEED_WX_TIME_H
274 #error "Please define your compiler's Unicode conventions in wxChar.h"
281 #if 0 // temporary - preserve binary compatibilty
283 typedef signed char wxSChar
;
284 typedef unsigned char wxUChar
;
287 #define wxSChar signed char
288 #define wxUChar unsigned char
294 #define wxIsalnum isalnum
295 #define wxIsalpha isalpha
296 #define wxIsctrl isctrl
297 #define wxIsdigit isdigit
298 #define wxIsgraph isgraph
299 #define wxIslower islower
300 #define wxIsprint isprint
301 #define wxIspunct ispunct
302 #define wxIsspace isspace
303 #define wxIsupper isupper
304 #define wxIsxdigit isxdigit
305 #define wxTolower tolower
306 #define wxToupper toupper
309 #define wxSetlocale setlocale
311 // string.h functions
312 #define wxStricmp strcasecmp
313 // #define wxStrtok strtok_r // this needs a configure check
315 // leave the rest to defaults below
316 #define wxNEED_WX_STRING_H
317 #define wxNEED_WX_STDIO_H
318 #define wxNEED_WX_STDLIB_H
319 #define wxNEED_WX_TIME_H
322 #endif//TCHAR-aware compilers
324 // define wxStricmp for various compilers without Unicode possibilities
325 #if !defined(wxStricmp) && !wxUSE_UNICODE
326 #if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__SALFORDC__)
327 #define wxStricmp stricmp
328 #elif defined(__SC__) || defined(__VISUALC__) || (defined(__MWERKS) && defined(__INTEL__))
329 #define wxStricmp _stricmp
330 #elif defined(__UNIX__) || defined(__GNUWIN32__)
331 #define wxStricmp strcasecmp
332 #elif defined(__MWERKS__) && !defined(__INTEL__)
333 // use wxWindows' implementation
335 // if you leave wxStricmp undefined, wxWindows' implementation will be used
336 #error "Please define string case-insensitive compare for your OS/compiler"
340 // if we need to define for standard headers, and we're not using Unicode,
341 // just define to standard C library routines
343 #ifdef wxNEED_WX_STRING_H
344 #define wxStrcat strcat
345 #define wxStrchr strchr
346 #define wxStrcmp strcmp
347 #define wxStrcoll strcoll
348 #define wxStrcpy strcpy
349 #define wxStrcspn strcspn
350 #define wxStrdup strdup
351 #define wxStrlen_ strlen // used in wxStrlen inline function
352 #define wxStrncat strncat
353 #define wxStrncmp strncmp
354 #define wxStrncpy strncpy
355 #define wxStrpbrk strpbrk
356 #define wxStrrchr strrchr
357 #define wxStrspn strspn
358 #define wxStrstr strstr
359 #define wxStrtod strtod
360 #define wxStrtol strtol
361 #define wxStrtoul strtoul
362 #define wxStrxfrm strxfrm
363 #undef wxNEED_WX_STRING_H
366 #ifdef wxNEED_WX_STDIO_H
367 #define wxFgetc fgetc
368 #define wxFgetchar fgetchar
369 #define wxFgets fgets
370 #define wxFopen fopen
371 #define wxFputc fputc
372 #define wxFputchar fputchar
373 #define wxFprintf fprintf
374 #define wxFreopen freopen
375 #define wxFscanf fscanf
377 #define wxGetchar getchar
379 #define wxPerror perror
380 #define wxPrintf printf
382 #define wxPutchar putchar
384 #define wxRemove remove
385 #define wxRename rename
386 #define wxScanf scanf
387 #define wxSprintf sprintf
388 #define wxSscanf sscanf
389 #define wxTmpnam tmpnam
390 #define wxUngetc ungetc
391 #define wxVfprint vfprintf
392 #define wxVprintf vprintf
393 #define wxVsscanf vsscanf
394 #define wxVsprintf vsprintf
395 #undef wxNEED_WX_STDIO_H
398 #ifdef wxNEED_WX_STDLIB_H
402 #define wxGetenv getenv
403 #define wxSystem system
404 #undef wxNEED_WX_STDLIB_H
407 #ifdef wxNEED_WX_TIME_H
408 #define wxAsctime asctime
409 #define wxCtime ctime
410 #define wxStrftime strftime
411 #undef wxNEED_WX_TIME_H
415 #if defined(wxNEED_WCSLEN) && wxUSE_UNICODE
416 #define wcslen wxStrlen
420 /// checks whether the passed in pointer is NULL and if the string is empty
421 inline bool WXDLLEXPORT
wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
423 #ifndef wxNEED_WX_STRING_H
424 /// safe version of strlen() (returns 0 if passed NULL pointer)
425 inline size_t WXDLLEXPORT
wxStrlen(const wxChar
*psz
)
426 { return psz
? wxStrlen_(psz
) : 0; }
430 // multibyte<->widechar conversion
431 size_t WXDLLEXPORT
wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
432 size_t WXDLLEXPORT
wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
434 #define wxMB2WX wxMB2WC
435 #define wxWX2MB wxWC2MB
436 #define wxWC2WX wxStrncpy
437 #define wxWX2WC wxStrncpy
439 #define wxMB2WX wxStrncpy
440 #define wxWX2MB wxStrncpy
441 #define wxWC2WX wxWC2MB
442 #define wxWX2WC wxMB2WC
445 bool WXDLLEXPORT
wxOKlibc(); // for internal use
447 // if libc versions are not available, use replacements defined in wxchar.cpp
449 wxChar
* WXDLLEXPORT
wxStrdup(const wxChar
*psz
);
453 int WXDLLEXPORT
wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
);
457 wxChar
* WXDLLEXPORT
wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
461 wxChar
* WXDLLEXPORT
wxSetlocale(int category
, const wxChar
*locale
);
464 #ifdef wxNEED_WCSLEN // for use in buffer.h
465 size_t WXDLLEXPORT
wcslen(const wchar_t *s
);
468 #ifdef wxNEED_WX_CTYPE_H
469 int WXDLLEXPORT
wxIsalnum(wxChar ch
);
470 int WXDLLEXPORT
wxIsalpha(wxChar ch
);
471 int WXDLLEXPORT
wxIsctrl(wxChar ch
);
472 int WXDLLEXPORT
wxIsdigit(wxChar ch
);
473 int WXDLLEXPORT
wxIsgraph(wxChar ch
);
474 int WXDLLEXPORT
wxIslower(wxChar ch
);
475 int WXDLLEXPORT
wxIsprint(wxChar ch
);
476 int WXDLLEXPORT
wxIspunct(wxChar ch
);
477 int WXDLLEXPORT
wxIsspace(wxChar ch
);
478 int WXDLLEXPORT
wxIsupper(wxChar ch
);
479 int WXDLLEXPORT
wxIsxdigit(wxChar ch
);
480 int WXDLLEXPORT
wxTolower(wxChar ch
);
481 int WXDLLEXPORT
wxToupper(wxChar ch
);
484 #ifdef wxNEED_WX_STRING_H
485 wxChar
* WXDLLEXPORT
wxStrcat(wxChar
*dest
, const wxChar
*src
);
486 wxChar
* WXDLLEXPORT
wxStrchr(const wxChar
*s
, wxChar c
);
487 int WXDLLEXPORT
wxStrcmp(const wxChar
*s1
, const wxChar
*s2
);
488 int WXDLLEXPORT
wxStrcoll(const wxChar
*s1
, const wxChar
*s2
);
489 wxChar
* WXDLLEXPORT
wxStrcpy(wxChar
*dest
, const wxChar
*src
);
490 size_t WXDLLEXPORT
wxStrcspn(const wxChar
*s
, const wxChar
*reject
);
491 size_t WXDLLEXPORT
wxStrlen(const wxChar
*s
);
492 wxChar
* WXDLLEXPORT
wxStrncat(wxChar
*dest
, const wxChar
*src
, size_t n
);
493 int WXDLLEXPORT
wxStrncmp(const wxChar
*s1
, const wxChar
*s2
, size_t n
);
494 wxChar
* WXDLLEXPORT
wxStrncpy(wxChar
*dest
, const wxChar
*src
, size_t n
);
495 wxChar
* WXDLLEXPORT
wxStrpbrk(const wxChar
*s
, const wxChar
*accept
);
496 wxChar
* WXDLLEXPORT
wxStrrchr(const wxChar
*s
, wxChar c
);
497 size_t WXDLLEXPORT
wxStrspn(const wxChar
*s
, const wxChar
*accept
);
498 wxChar
* WXDLLEXPORT
wxStrstr(const wxChar
*haystack
, const wxChar
*needle
);
499 double WXDLLEXPORT
wxStrtod(const wxChar
*nptr
, wxChar
**endptr
);
500 long int WXDLLEXPORT
wxStrtol(const wxChar
*nptr
, wxChar
**endptr
, int base
);
501 unsigned long int WXDLLEXPORT
wxStrtoul(const wxChar
*nptr
, wxChar
**endptr
, int base
);
502 size_t WXDLLEXPORT
wxStrxfrm(wxChar
*dest
, const wxChar
*src
, size_t n
);
505 #ifdef wxNEED_WX_STDIO_H
508 int WXDLLEXPORT
wxPrintf(const wxChar
*fmt
, ...);
509 int WXDLLEXPORT
wxVprintf(const wxChar
*fmt
, va_list argptr
);
510 int WXDLLEXPORT
wxFprintf(FILE *stream
, const wxChar
*fmt
, ...);
511 int WXDLLEXPORT
wxVfprintf(FILE *stream
, const wxChar
*fmt
, va_list argptr
);
512 int WXDLLEXPORT
wxSprintf(wxChar
*buf
, const wxChar
*fmt
, ...);
513 int WXDLLEXPORT
wxVsprintf(wxChar
*buf
, const wxChar
*fmt
, va_list argptr
);
514 int WXDLLEXPORT
wxSscanf(const wxChar
*buf
, const wxChar
*fmt
, ...);
515 int WXDLLEXPORT
wxVsscanf(const wxChar
*buf
, const wxChar
*fmt
, va_list argptr
);
519 double WXDLLEXPORT
wxAtof(const wxChar
*psz
);
522 #ifdef wxNEED_WX_STDLIB_H
523 int WXDLLEXPORT
wxAtoi(const wxChar
*psz
);
524 long WXDLLEXPORT
wxAtol(const wxChar
*psz
);
525 wxChar
* WXDLLEXPORT
wxGetenv(const wxChar
*name
);
526 int WXDLLEXPORT
wxSystem(const wxChar
*psz
);