5d044444647382543135fcd34823f7aa9ed232b7
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 // Undef UNICODE_UCS2 and UNICODE_UCS4 if they are defined to 0
36 // Ensure that both UNICODE and _UNICODE are defined
51 // Windows always use UCS-2
52 #define UNICODE_UCS2 1
56 #define _tcstoll wcstoll
57 #define _tcstoull wcstoull
59 #define _ERR_error_tstring ERR_error_string_W
63 #define _tcstoll strtoll
64 #define _tcstoull strtoull
66 #define _ERR_error_tstring ERR_error_string
70 #define ICONV_DEFAULT_CODEPAGE "ACP"
72 #define ucs2_strlen wcslen
73 #define ucs2_strdup wcsdup
74 #define ucs2_strncpy wcsncpy
76 #define ucs2_to_mb(wstr, wlen, mstr, mlen) WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, wstr, wlen, mstr, mlen, NULL, NULL)
77 #define mb_to_ucs2(mstr, mlen, wstr, wlen) MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mstr, mlen, wstr, wlen)
79 #define UCS2CHAR WCHAR
81 #elif defined(__SYMBIAN32__)
83 // Ensure that both UNICODE and _UNICODE are defined
96 // Symbian always use UCS-2
97 #define UNICODE_UCS2 1
100 #define WCHAR TText16
101 #define UCS2CHAR TText16
109 #else /* not _WIN32 and __SYMBIAN32__ */
111 #if defined(_NETWARE) && defined(__GNUC__) && defined(__cplusplus)
113 #define _WCHAR_T_DEFINED
114 #define wchar_t unsigned short
128 #define WCHAR wchar_t
130 #define UCS2CHAR wchar_t
132 #define UCS2CHAR unsigned short
135 #else /* wchar_t not presented */
137 #define WCHAR unsigned short
138 #define UCS2CHAR unsigned short
141 #define UNICODE_UCS2 1
145 // Use system wide character functions if system's wchar_t is 2 bytes long
149 #define ucs2_strlen wcslen
151 #define wcslen ucs2_strlen
155 #define ucs2_strdup wcsdup
157 #define wcsdup ucs2_strdup
161 #define ucs2_strncpy wcsncpy
163 #define wcsncpy ucs2_strncpy
168 // On some old systems, ctype.h defines _T macro, so we include it
169 // before our definition and do an undef
176 #define TCHAR wchar_t
179 #define _tcscpy wcscpy
180 #define _tcsncpy wcsncpy
181 #define _tcslen wcslen
182 #define _tcschr wcschr
183 #define _tcsrchr wcsrchr
184 #define _tcscmp wcscmp
185 #define _tcsicmp wcsicmp
186 #define _tcsncmp wcsncmp
187 #define _tcsnicmp wcsnicmp
188 #define _tprintf nx_wprintf
189 #define _ftprintf nx_fwprintf
190 #define _sntprintf nx_swprintf
191 #define _vtprintf nx_vwprintf
192 #define _vftprintf nx_vfwprintf
193 #define _vsntprintf nx_vswprintf
194 #define _stscanf swscanf
195 #define _tfopen wfopen
196 #define _fgetts fgetws
197 #define _fputts fputws
198 #define _tcstol wcstol
199 #define _tcstoul wcstoul
200 #define _tcstoll wcstoll
201 #define _tcstoull wcstoull
202 #define _tcstod wcstod
203 #define _tcsdup wcsdup
204 #define _tcsupr wcsupr
205 #define _tcsspn wcsspn
206 #define _tcscspn wcscspn
207 #define _tcsstr wcsstr
208 #define _tcscat wcscat
209 #define _tcsncat wcsncat
210 #define _tcspbrk wcspbrk
211 #define _tcstok wcstok
213 #define _taccess waccess
215 #define _tunlink wunlink
216 #define _trename wrename
217 #define _tremove wremove
218 #define _tcsftime wcsftime
219 #define _tctime wctime
220 #define _istspace iswspace
221 #define _istdigit iswdigit
222 #define _istxdigit iswxdigit
223 #define _istalpha iswalpha
224 #define _istupper iswupper
225 #define _tgetenv wgetenv
226 #define _tmkdir wmkdir
227 #define _tcserror wcserror
228 #define _tcserror_r wcserror_r
236 #define _tcscpy strcpy
237 #define _tcsncpy strncpy
238 #define _tcslen strlen
239 #define _tcschr strchr
240 #define _tcsrchr strrchr
241 #define _tcscmp strcmp
242 #define _tcsicmp stricmp
243 #define _tcsncmp strncmp
244 #define _tcsnicmp strnicmp
245 #define _tprintf printf
246 #define _stprintf sprintf
247 #define _ftprintf fprintf
248 #define _sntprintf snprintf
249 #define _vtprintf vprintf
250 #define _vstprintf vsprintf
251 #define _vsntprintf vsnprintf
252 #define _stscanf sscanf
253 #define _tfopen fopen
254 #define _fgetts fgets
255 #define _fputts fputs
256 #define _tcstol strtol
257 #define _tcstoul strtoul
258 #define _tcstoll strtoll
259 #define _tcstoull strtoull
260 #define _tcstod strtod
261 #define _tcsdup strdup
262 #define _tcsupr strupr
263 #define _tcsspn strspn
264 #define _tcscspn strcspn
265 #define _tcsstr strstr
266 #define _tcscat strcat
267 #define _tcsncat strncat
268 #define _tcspbrk strpbrk
269 #define _tcstok strtok
271 #define _taccess access
273 #define _tunlink unlink
274 #define _trename rename
275 #define _tremove remove
276 #define _tcsftime strftime
277 #define _tctime ctime
278 #define _istspace isspace
279 #define _istdigit isdigit
280 #define _istxdigit isxdigit
281 #define _istalpha isalpha
282 #define _istupper isupper
283 #define _tgetenv getenv
284 #define _tmkdir mkdir
285 #define _tcserror strerror
286 #define _tcserror_r strerror_r
288 #define _ERR_error_tstring ERR_error_string
293 #define CP_UTF8 65001
294 #define MB_PRECOMPOSED 0x00000001
295 #define WC_COMPOSITECHECK 0x00000002
296 #define WC_DEFAULTCHAR 0x00000004
298 // Default codepage for iconv()
299 #if HAVE_ICONV_ISO_8859_1
300 #define ICONV_DEFAULT_CODEPAGE "ISO-8859-1"
301 #elif HAVE_ICONV_ISO8859_1
302 #define ICONV_DEFAULT_CODEPAGE "ISO8859-1"
303 #elif HAVE_ICONV_ASCII
304 #define ICONV_DEFAULT_CODEPAGE "ASCII"
306 #define ICONV_DEFAULT_CODEPAGE ""
311 // Define UCS2-specific helper functions as define to wide string helper functions if possible
313 #define UCS2StringFromMBString WideStringFromMBString
314 #define MBStringFromUCS2String MBStringFromWideString
319 #define _t_inet_addr inet_addr_w
321 #define _t_inet_addr inet_addr
325 // Check that either UNICODE_UCS2 or UNICODE_UCS4 are defined
326 #if !defined(UNICODE_UCS2) && !defined(UNICODE_UCS4)
327 #error Neither UNICODE_UCS2 nor UNICODE_UCS4 are defined
330 #endif /* _unicode_h_ */