]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/wxchar.h
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 // Windows (VC++) has broad TCHAR support
25 #if defined(__VISUALC__) && defined(__WIN32__)
28 #if wxUSE_UNICODE // temporary - preserve binary compatibility
29 typedef _TCHAR wxChar
;
30 typedef _TSCHAR wxSChar
;
31 typedef _TUCHAR wxUChar
;
34 #define wxSChar signed char
35 #define wxUChar unsigned char
39 #define wxIsalnum _istalnum
40 #define wxIsalpha _istalpha
41 #define wxIsctrl _istctrl
42 #define wxIsdigit _istdigit
43 #define wxIsgraph _istgraph
44 #define wxIslower _istlower
45 #define wxIsprint _istprint
46 #define wxIspunct _istpunct
47 #define wxIsspace _istspace
48 #define wxIsupper _istupper
49 #define wxIsxdigit _istxdigit
50 #define wxTolower _totlower
51 #define wxToupper _totupper
54 #define wxSetlocale _tsetlocale
57 #define wxStrcat _tcscat
58 #define wxStrchr _tcschr
59 #define wxStrcmp _tcscmp
60 #define wxStrcoll _tcscoll
61 #define wxStrcpy _tcscpy
62 #define wxStrcspn _tcscspn
63 #define wxStrftime _tcsftime
64 #define wxStrncat _tcsncat
65 #define wxStrncmp _tcsncmp
66 #define wxStrncpy _tcsncpy
67 #define wxStrpbrk _tcspbrk
68 #define wxStrrchr _tcsrchr
69 #define wxStrspn _tcsspn
70 #define wxStrstr _tcsstr
71 #define wxStrtod _tcstod
72 // is there a _tcstok[_r] ?
73 #define wxStrtol _tcstol
74 #define wxStrtoul _tcstoul
75 #define wxStrxfrm _tcsxfrm
78 #define wxFgetc _fgettc
79 #define wxFgetchar _fgettchar
80 #define wxFgets _fgetts
81 #define wxFopen _tfopen
82 #define wxFputc _fputtc
83 #define wxFputchar _fputtchar
84 #define wxFprintf _ftprintf
85 #define wxFreopen _tfreopen
86 #define wxFscanf _ftscanf
88 #define wxGetchar _gettchar
90 #define wxPerror _tperror
91 #define wxPrintf _tprintf
93 #define wxPutchar _puttchar
95 #define wxRemove _tremove
96 #define wxRename _trename
97 #define wxScanf _tscanf
98 #define wxSprintf _stprintf
99 #define wxSscanf _stscanf
100 #define wxTmpnam _ttmpnam
101 #define wxUngetc _tungetc
102 #define wxVfprint _vftprintf
103 #define wxVprintf _vtprintf
104 #define wxVsprintf _vstprintf
106 // stdlib.h functions
112 #define wxGetenv _tgetenv
113 #define wxSystem _tsystem
116 #define wxAsctime _tasctime
117 #define wxCtime _tctime
119 // #elif defined(XXX)
120 // #include XXX-specific files here
121 // typeddef YYY wxChar;
123 // translate wxZZZ names
125 #else//!Windows (VC++)
127 // check whether we are doing Unicode
133 // this is probably glibc-specific
134 #if defined(__WCHAR_TYPE__)
136 typedef __WCHAR_TYPE__ wxChar
;
137 typedef signed __WCHAR_TYPE__ wxSChar
;
138 typedef unsigned __WCHAR_TYPE__ wxUChar
;
142 // ctype.h functions (wctype.h)
143 #define wxIsalnum iswalnum
144 #define wxIsalpha iswalpha
145 #define wxIsctrl iswcntrl
146 #define wxIsdigit iswdigit
147 #define wxIsgraph iswgraph
148 #define wxIslower iswlower
149 #define wxIsprint iswprint
150 #define wxIspunct iswpunct
151 #define wxIsspace iswspace
152 #define wxIsupper iswupper
153 #define wxIsxdigit iswxdigit
154 #define wxTolower towlower
155 #define wxToupper towupper
157 // string.h functions (wchar.h)
158 #define wxStrcat wcscat
159 #define wxStrchr wcschr
160 #define wxStrcmp wcscmp
161 #define wxStrcoll wcscoll
162 #define wxStrcpy wcscpy
163 #define wxStrcspn wcscspn
164 #define wxStrncat wcsncat
165 #define wxStrncmp wcsncmp
166 #define wxStrncpy wcsncpy
167 #define wxStrpbrk wcspbrk
168 #define wxStrrchr wcsrchr
169 #define wxStrspn wcsspn
170 #define wxStrstr wcsstr
171 #define wxStrtod wcstod
172 #define wxStrtok wcstok
173 #define wxStrtol wcstol
174 #define wxStrtoul wcstoul
175 #define wxStrxfrm wcsxfrm
177 // glibc doesn't have wc equivalents of the other stuff
178 #define wxNEED_WX_STDIO_H
179 #define wxNEED_WX_STDLIB_H
180 #define wxNEED_WX_TIME_H
183 #error "Please define your compiler's Unicode conventions in wxChar.h"
190 #if 0 // temporary - preserve binary compatibilty
192 typedef signed char wxSChar
;
193 typedef unsigned char wxUChar
;
196 #define wxSChar signed char
197 #define wxUChar unsigned char
203 #define wxIsalnum isalnum
204 #define wxIsalpha isalpha
205 #define wxIsctrl isctrl
206 #define wxIsdigit isdigit
207 #define wxIsgraph isgraph
208 #define wxIslower islower
209 #define wxIsprint isprint
210 #define wxIspunct ispunct
211 #define wxIsspace isspace
212 #define wxIsupper isupper
213 #define wxIsxdigit isxdigit
214 #define wxTolower tolower
215 #define wxToupper toupper
218 #define wxSetlocale setlocale
220 // string.h functions
221 #define wxStrcat strcat
222 #define wxStrchr strchr
223 #define wxStrcmp strcmp
224 #define wxStrcoll strcoll
225 #define wxStrcpy strcpy
226 #define wxStrcspn strcspn
227 #define wxStrdup strdup
228 #define wxStrncat strncat
229 #define wxStrncmp strncmp
230 #define wxStrncpy strncpy
231 #define wxStrpbrk strpbrk
232 #define wxStrrchr strrchr
233 #define wxStrspn strspn
234 #define wxStrstr strstr
235 #define wxStrtod strtod
236 // #define wxStrtok strtok_r // this needs a configure check
237 #define wxStrtol strtol
238 #define wxStrtoul strtoul
239 #define wxStrxfrm strxfrm
242 #define wxFgetc fgetc
243 #define wxFgetchar fgetchar
244 #define wxFgets fgets
245 #define wxFopen fopen
246 #define wxFputc fputc
247 #define wxFputchar fputchar
248 #define wxFprintf fprintf
249 #define wxFreopen freopen
250 #define wxFscanf fscanf
252 #define wxGetchar getchar
254 #define wxPerror perror
255 #define wxPrintf printf
257 #define wxPutchar putchar
259 #define wxRemove remove
260 #define wxRename rename
261 #define wxScanf scanf
262 #define wxSprintf sprintf
263 #define wxSscanf sscanf
264 #define wxTmpnam tmpnam
265 #define wxUngetc ungetc
266 #define wxVfprint vfprintf
267 #define wxVprintf vprintf
268 #define wxVsprintf vsprintf
270 // stdlib.h functions
274 #define wxGetenv getenv
275 #define wxSystem system
278 #define wxAsctime asctime
279 #define wxCtime ctime
280 #define wxStrftime strftime
286 /// checks whether the passed in pointer is NULL and if the string is empty
287 inline bool WXDLLEXPORT
wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
289 /// safe version of strlen() (returns 0 if passed NULL pointer)
290 inline size_t WXDLLEXPORT
wxStrlen(const wxChar
*psz
)
291 #if defined(__VISUALC__)
292 { return psz
? _tcslen(psz
) : 0; }
294 { return psz
? wcslen(psz
) : 0; }
296 { return psz
? strlen(psz
) : 0; }
299 /// portable strcasecmp/_stricmp
300 inline int WXDLLEXPORT
wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
)
301 #if defined(__VISUALC__)
302 { return _tcsicmp(psz1
, psz2
); }
303 #elif defined(__BORLANDC__) && !wxUSE_UNICODE
304 { return stricmp(psz1
, psz2
); }
305 #elif defined(__UNIX__) || defined(__GNUWIN32__)
307 { return strcasecmp(psz1
, psz2
); }
308 #else // glibc doesn't seem to have wide char equivalent
310 register wxChar c1
, c2
;
312 c1
= wxTolower(*psz1
++);
313 c2
= wxTolower(*psz2
++);
314 } while ( c1
&& (c1
== c2
) );
320 // almost all compilers/libraries provide this function (unfortunately under
321 // different names), that's why we don't implement our own which will surely
322 // be more efficient than this code (uncomment to use):
324 register wxChar c1, c2;
326 c1 = wxTolower(*psz1++);
327 c2 = wxTolower(*psz2++);
328 } while ( c1 && (c1 == c2) );
333 #error "Please define string case-insensitive compare for your OS/compiler"
334 #endif // OS/compiler
336 // multibyte<->widechar conversion
337 size_t WXDLLEXPORT
wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
338 size_t WXDLLEXPORT
wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
340 #define wxMB2WX wxMB2WC
341 #define wxWX2MB wxWC2MB
342 #define wxWC2WX wxStrncpy
343 #define wxWX2WC wxStrncpy
345 #define wxMB2WX wxStrncpy
346 #define wxWX2MB wxStrncpy
347 #define wxWC2WX wxWC2MB
348 #define wxWX2WC wxMB2WC
351 // if libc versions are not available, use replacements defined in wxchar.cpp
353 wxChar
* WXDLLEXPORT
wxStrdup(const wxChar
*psz
);
357 wxChar
* WXDLLEXPORT
wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
361 wxChar
* WXDLLEXPORT
wxSetlocale(int category
, const wxChar
*locale
);
364 #ifdef wxNEED_WX_STDIO_H
366 int WXDLLEXPORT
wxSprintf(wxChar
*buf
, const wxChar
*fmt
, ...);
367 int WXDLLEXPORT
wxVsprintf(wxChar
*buf
, const wxChar
*fmt
, va_list argptr
);
371 double WXDLLEXPORT
wxAtof(const wxChar
*psz
);
374 #ifdef wxNEED_WX_STDLIB_H
375 int WXDLLEXPORT
wxAtoi(const wxChar
*psz
);
376 long WXDLLEXPORT
wxAtol(const wxChar
*psz
);
377 wxChar
* WXDLLEXPORT
wxGetenv(const wxChar
*name
);
378 int WXDLLEXPORT
wxSystem(const wxChar
*psz
);