]>
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 #define wxStrtok _tcstok
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
109 #define wxGetenv _tgetenv
110 #define wxSystem _tsystem
113 #define wxAsctime _tasctime
114 #define wxCtime _tctime
116 // #elif defined(XXX)
117 // #include XXX-specific files here
118 // typeddef YYY wxChar;
120 // translate wxZZZ names
122 #else//!Windows (VC++)
124 // check whether we are doing Unicode
130 // this is probably glibc-specific
131 #if defined(__WCHAR_TYPE__)
133 typedef __WCHAR_TYPE__ wxChar
;
134 typedef signed __WCHAR_TYPE__ wxSChar
;
135 typedef unsigned __WCHAR_TYPE__ wxUChar
;
139 // ctype.h functions (wctype.h)
140 #define wxIsalnum iswalnum
141 #define wxIsalpha iswalpha
142 #define wxIsctrl iswcntrl
143 #define wxIsdigit iswdigit
144 #define wxIsgraph iswgraph
145 #define wxIslower iswlower
146 #define wxIsprint iswprint
147 #define wxIspunct iswpunct
148 #define wxIsspace iswspace
149 #define wxIsupper iswupper
150 #define wxIsxdigit iswxdigit
151 #define wxTolower towlower
152 #define wxToupper towupper
154 // string.h functions (wchar.h)
155 #define wxStrcat wcscat
156 #define wxStrchr wcschr
157 #define wxStrcmp wcscmp
158 #define wxStrcoll wcscoll
159 #define wxStrcpy wcscpy
160 #define wxStrcspn wcscspn
161 #define wxStrncat wcsncat
162 #define wxStrncmp wcsncmp
163 #define wxStrncpy wcsncpy
164 #define wxStrpbrk wcspbrk
165 #define wxStrrchr wcsrchr
166 #define wxStrspn wcsspn
167 #define wxStrstr wcsstr
168 #define wxStrtod wcstod
169 #define wxStrtok wcstok
170 #define wxStrtol wcstol
171 #define wxStrtoul wcstoul
172 #define wxStrxfrm wcsxfrm
174 // glibc doesn't have wc equivalents of the other stuff
175 // do we need to write wrappers for them?
178 #error "Please define your compiler's Unicode conventions in wxChar.h"
182 #if 0 // temporary - preserve binary compatibilty
184 typedef signed char wxSChar
;
185 typedef unsigned char wxUChar
;
188 #define wxSChar signed char
189 #define wxUChar unsigned char
195 #define wxIsalnum isalnum
196 #define wxIsalpha isalpha
197 #define wxIsctrl isctrl
198 #define wxIsdigit isdigit
199 #define wxIsgraph isgraph
200 #define wxIslower islower
201 #define wxIsprint isprint
202 #define wxIspunct ispunct
203 #define wxIsspace isspace
204 #define wxIsupper isupper
205 #define wxIsxdigit isxdigit
206 #define wxTolower tolower
207 #define wxToupper toupper
210 #define wxSetlocale setlocale
212 // string.h functions
213 #define wxStrcat strcat
214 #define wxStrchr strchr
215 #define wxStrcmp strcmp
216 #define wxStrcoll strcoll
217 #define wxStrcpy strcpy
218 #define wxStrcspn strcspn
219 #define wxStrncat strncat
220 #define wxStrncmp strncmp
221 #define wxStrncpy strncpy
222 #define wxStrpbrk strpbrk
223 #define wxStrrchr strrchr
224 #define wxStrspn strspn
225 #define wxStrstr strstr
226 #define wxStrtod strtod
227 #define wxStrtok strtok
228 #define wxStrtol strtol
229 #define wxStrtoul strtoul
230 #define wxStrxfrm strxfrm
233 #define wxFgetc fgetc
234 #define wxFgetchar fgetchar
235 #define wxFgets fgets
236 #define wxFopen fopen
237 #define wxFputc fputc
238 #define wxFputchar fputchar
239 #define wxFprintf fprintf
240 #define wxFreopen freopen
241 #define wxFscanf fscanf
243 #define wxGetchar getchar
245 #define wxPerror perror
246 #define wxPrintf printf
248 #define wxPutchar putchar
250 #define wxRemove remove
251 #define wxRename rename
252 #define wxScanf scanf
253 #define wxSprintf sprintf
254 #define wxSscanf sscanf
255 #define wxTmpnam tmpnam
256 #define wxUngetc ungetc
257 #define wxVfprint vfprintf
258 #define wxVprintf vprintf
259 #define wxVsprintf vsprintf
261 // stdlib.h functions
264 #define wxGetenv getenv
265 #define wxSystem system
268 #define wxAsctime asctime
269 #define wxCtime ctime
270 #define wxStrftime strftime
276 /// checks whether the passed in pointer is NULL and if the string is empty
277 inline bool WXDLLEXPORT
wxIsEmpty(const wxChar
*p
) { return !p
|| !*p
; }
279 /// safe version of strlen() (returns 0 if passed NULL pointer)
280 inline size_t WXDLLEXPORT
wxStrlen(const wxChar
*psz
)
281 #if defined(__VISUALC__)
282 { return psz
? _tcslen(psz
) : 0; }
284 { return psz
? wcslen(psz
) : 0; }
286 { return psz
? strlen(psz
) : 0; }
289 /// portable strcasecmp/_stricmp
290 inline int WXDLLEXPORT
wxStricmp(const wxChar
*psz1
, const wxChar
*psz2
)
291 #if defined(__VISUALC__)
292 { return _tcsicmp(psz1
, psz2
); }
293 #elif defined(__BORLANDC__) && !wxUSE_UNICODE
294 { return stricmp(psz1
, psz2
); }
295 #elif defined(__UNIX__) || defined(__GNUWIN32__)
297 { return strcasecmp(psz1
, psz2
); }
298 #else // glibc doesn't seem to have wide char equivalent
300 register wxChar c1
, c2
;
302 c1
= wxTolower(*psz1
++);
303 c2
= wxTolower(*psz2
++);
304 } while ( c1
&& (c1
== c2
) );
310 // almost all compilers/libraries provide this function (unfortunately under
311 // different names), that's why we don't implement our own which will surely
312 // be more efficient than this code (uncomment to use):
314 register wxChar c1, c2;
316 c1 = wxTolower(*psz1++);
317 c2 = wxTolower(*psz2++);
318 } while ( c1 && (c1 == c2) );
323 #error "Please define string case-insensitive compare for your OS/compiler"
324 #endif // OS/compiler