]>
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
107 #define wxAtof _ttof /* does this exist? */
110 #define wxGetenv _tgetenv
111 #define wxSystem _tsystem
114 #define wxAsctime _tasctime
115 #define wxCtime _tctime
117 // #elif defined(XXX)
118 // #include XXX-specific files here
119 // typeddef YYY wxChar;
121 // translate wxZZZ names
123 #else//!Windows (VC++)
125 // check whether we are doing Unicode
131 // this is probably glibc-specific
132 #if defined(__WCHAR_TYPE__)
134 typedef __WCHAR_TYPE__ wxChar
;
135 typedef signed __WCHAR_TYPE__ wxSChar
;
136 typedef unsigned __WCHAR_TYPE__ wxUChar
;
140 // ctype.h functions (wctype.h)
141 #define wxIsalnum iswalnum
142 #define wxIsalpha iswalpha
143 #define wxIsctrl iswcntrl
144 #define wxIsdigit iswdigit
145 #define wxIsgraph iswgraph
146 #define wxIslower iswlower
147 #define wxIsprint iswprint
148 #define wxIspunct iswpunct
149 #define wxIsspace iswspace
150 #define wxIsupper iswupper
151 #define wxIsxdigit iswxdigit
152 #define wxTolower towlower
153 #define wxToupper towupper
155 // string.h functions (wchar.h)
156 #define wxStrcat wcscat
157 #define wxStrchr wcschr
158 #define wxStrcmp wcscmp
159 #define wxStrcoll wcscoll
160 #define wxStrcpy wcscpy
161 #define wxStrcspn wcscspn
162 #define wxStrncat wcsncat
163 #define wxStrncmp wcsncmp
164 #define wxStrncpy wcsncpy
165 #define wxStrpbrk wcspbrk
166 #define wxStrrchr wcsrchr
167 #define wxStrspn wcsspn
168 #define wxStrstr wcsstr
169 #define wxStrtod wcstod
170 #define wxStrtok wcstok
171 #define wxStrtol wcstol
172 #define wxStrtoul wcstoul
173 #define wxStrxfrm wcsxfrm
175 // glibc doesn't have wc equivalents of the other stuff
176 #define wxNEED_WX_STDIO_H
177 #define wxNEED_WX_STDLIB_H
178 #define wxNEED_WX_TIME_H
181 #error "Please define your compiler's Unicode conventions in wxChar.h"
188 #if 0 // temporary - preserve binary compatibilty
190 typedef signed char wxSChar
;
191 typedef unsigned char wxUChar
;
194 #define wxSChar signed char
195 #define wxUChar unsigned char
201 #define wxIsalnum isalnum
202 #define wxIsalpha isalpha
203 #define wxIsctrl isctrl
204 #define wxIsdigit isdigit
205 #define wxIsgraph isgraph
206 #define wxIslower islower
207 #define wxIsprint isprint
208 #define wxIspunct ispunct
209 #define wxIsspace isspace
210 #define wxIsupper isupper
211 #define wxIsxdigit isxdigit
212 #define wxTolower tolower
213 #define wxToupper toupper
216 #define wxSetlocale setlocale
218 // string.h functions
219 #define wxStrcat strcat
220 #define wxStrchr strchr
221 #define wxStrcmp strcmp
222 #define wxStrcoll strcoll
223 #define wxStrcpy strcpy
224 #define wxStrcspn strcspn
225 #define wxStrdup strdup
226 #define wxStrncat strncat
227 #define wxStrncmp strncmp
228 #define wxStrncpy strncpy
229 #define wxStrpbrk strpbrk
230 #define wxStrrchr strrchr
231 #define wxStrspn strspn
232 #define wxStrstr strstr
233 #define wxStrtod strtod
234 // #define wxStrtok strtok_r // this needs a configure check
235 #define wxStrtol strtol
236 #define wxStrtoul strtoul
237 #define wxStrxfrm strxfrm
240 #define wxFgetc fgetc
241 #define wxFgetchar fgetchar
242 #define wxFgets fgets
243 #define wxFopen fopen
244 #define wxFputc fputc
245 #define wxFputchar fputchar
246 #define wxFprintf fprintf
247 #define wxFreopen freopen
248 #define wxFscanf fscanf
250 #define wxGetchar getchar
252 #define wxPerror perror
253 #define wxPrintf printf
255 #define wxPutchar putchar
257 #define wxRemove remove
258 #define wxRename rename
259 #define wxScanf scanf
260 #define wxSprintf sprintf
261 #define wxSscanf sscanf
262 #define wxTmpnam tmpnam
263 #define wxUngetc ungetc
264 #define wxVfprint vfprintf
265 #define wxVprintf vprintf
266 #define wxVsprintf vsprintf
268 // stdlib.h functions
272 #define wxGetenv getenv
273 #define wxSystem system
276 #define wxAsctime asctime
277 #define wxCtime ctime
278 #define wxStrftime strftime
284 /// checks whether the passed in pointer is NULL and if the string is empty
285 inline bool WXDLLEXPORT
wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
287 /// safe version of strlen() (returns 0 if passed NULL pointer)
288 inline size_t WXDLLEXPORT
wxStrlen(const wxChar
*psz
)
289 #if defined(__VISUALC__)
290 { return psz
? _tcslen(psz
) : 0; }
292 { return psz
? wcslen(psz
) : 0; }
294 { return psz
? strlen(psz
) : 0; }
297 /// portable strcasecmp/_stricmp
298 inline int WXDLLEXPORT
wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
)
299 #if defined(__VISUALC__)
300 { return _tcsicmp(psz1
, psz2
); }
301 #elif defined(__BORLANDC__) && !wxUSE_UNICODE
302 { return stricmp(psz1
, psz2
); }
303 #elif defined(__UNIX__) || defined(__GNUWIN32__)
305 { return strcasecmp(psz1
, psz2
); }
306 #else // glibc doesn't seem to have wide char equivalent
308 register wxChar c1
, c2
;
310 c1
= wxTolower(*psz1
++);
311 c2
= wxTolower(*psz2
++);
312 } while ( c1
&& (c1
== c2
) );
318 // almost all compilers/libraries provide this function (unfortunately under
319 // different names), that's why we don't implement our own which will surely
320 // be more efficient than this code (uncomment to use):
322 register wxChar c1, c2;
324 c1 = wxTolower(*psz1++);
325 c2 = wxTolower(*psz2++);
326 } while ( c1 && (c1 == c2) );
331 #error "Please define string case-insensitive compare for your OS/compiler"
332 #endif // OS/compiler
334 // multibyte<->widechar conversion
335 size_t WXDLLEXPORT
wxMB2WC(wchar_t *buf
, const char *psz
, size_t n
);
336 size_t WXDLLEXPORT
wxWC2MB(char *buf
, const wchar_t *psz
, size_t n
);
338 #define wxMB2WX wxMB2WC
339 #define wxWX2MB wxWC2MB
340 #define wxWC2WX wxStrncpy
341 #define wxWX2WC wxStrncpy
343 #define wxMB2WX wxStrncpy
344 #define wxWX2MB wxStrncpy
345 #define wxWC2WX wxWC2MB
346 #define wxWX2WC wxMB2WC
349 // if libc versions are not available, use replacements defined in wxchar.cpp
351 wxChar
* WXDLLEXPORT
wxStrdup(const wxChar
*psz
);
355 wxChar
* WXDLLEXPORT
wxStrtok(wxChar
*psz
, const wxChar
*delim
, wxChar
**save_ptr
);
359 wxChar
* WXDLLEXPORT
wxSetlocale(int category
, const wxChar
*locale
);
362 #ifdef wxNEED_WX_STDIO_H
364 int WXDLLEXPORT
wxSprintf(wxChar
*buf
, const wxChar
*fmt
, ...);
365 int WXDLLEXPORT
wxVsprintf(wxChar
*buf
, const wxChar
*fmt
, va_list argptr
);
368 #ifdef wxNEED_WX_STDLIB_H
369 double WXDLLEXPORT
wxAtof(const wxChar
*psz
);
370 int WXDLLEXPORT
wxAtoi(const wxChar
*psz
);
371 long WXDLLEXPORT
wxAtol(const wxChar
*psz
);
372 wxChar
* WXDLLEXPORT
wxGetenv(const wxChar
*name
);
373 int WXDLLEXPORT
wxSystem(const wxChar
*psz
);