[UNICODE]
[reactos.git] / reactos / include / reactos / wine / unicode.h
1 /*
2 * PROJECT: ReactOS
3 * LICENSE: LGPL v2.1 or any later version
4 * PURPOSE: Map Wine's Unicode functions to native wcs* functions wherever possible
5 * AUTHORS: ?
6 */
7
8 #ifndef __WINE_WINE_UNICODE_H
9 #define __WINE_WINE_UNICODE_H
10
11 #include <stdarg.h>
12 #include <stdlib.h>
13 #include <wchar.h>
14
15 #include <windef.h>
16 #include <winbase.h>
17 #include <winnls.h>
18
19 #ifndef WINE_UNICODE_API
20 #define WINE_UNICODE_API
21 #endif
22
23 #ifndef WINE_UNICODE_INLINE
24 #define WINE_UNICODE_INLINE static inline
25 #endif
26
27 #define memicmpW(s1,s2,n) _wcsnicmp((const wchar_t *)(s1),(const wchar_t *)(s2),(n))
28 #define strlenW(s) wcslen((const wchar_t *)(s))
29 #define strcpyW(d,s) wcscpy((wchar_t *)(d),(const wchar_t *)(s))
30 #define strcatW(d,s) wcscat((wchar_t *)(d),(const wchar_t *)(s))
31 #define strcspnW(d,s) wcscspn((wchar_t *)(d),(const wchar_t *)(s))
32 #define strstrW(d,s) wcsstr((const wchar_t *)(d),(const wchar_t *)(s))
33 #define strtolW(s,e,b) wcstol((const wchar_t *)(s),(wchar_t **)(e),(b))
34 #define strchrW(s,c) wcschr((const wchar_t *)(s),(wchar_t)(c))
35 #define strrchrW(s,c) wcsrchr((const wchar_t *)(s),(wchar_t)(c))
36 #define strncmpW(s1,s2,n) wcsncmp((const wchar_t *)(s1),(const wchar_t *)(s2),(n))
37 #define strncpyW(s1,s2,n) wcsncpy((wchar_t *)(s1),(const wchar_t *)(s2),(n))
38 #define strcmpW(s1,s2) wcscmp((const wchar_t *)(s1),(const wchar_t *)(s2))
39 #define strcmpiW(s1,s2) _wcsicmp((const wchar_t *)(s1),(const wchar_t *)(s2))
40 #define strncmpiW(s1,s2,n) _wcsnicmp((const wchar_t *)(s1),(const wchar_t *)(s2),(n))
41 #define strtoulW(s1,s2,b) wcstoul((const wchar_t *)(s1),(wchar_t **)(s2),(b))
42 #define strspnW(str, accept) wcsspn((const wchar_t *)(str), (const wchar_t *)(accept))
43 #define strpbrkW(str, accept) wcspbrk((const wchar_t *)(str), (const wchar_t *)(accept))
44 #define tolowerW(n) towlower((n))
45 #define toupperW(n) towupper((n))
46 #define islowerW(n) iswlower((n))
47 #define isupperW(n) iswupper((n))
48 #define isalphaW(n) iswalpha((n))
49 #define isalnumW(n) iswalnum((n))
50 #define isdigitW(n) iswdigit((n))
51 #define isxdigitW(n) iswxdigit((n))
52 #define isspaceW(n) iswspace((n))
53 #define iscntrlW(n) iswcntrl((n))
54 #define atoiW(s) _wtoi((const wchar_t *)(s))
55 #define atolW(s) _wtol((const wchar_t *)(s))
56 #define strlwrW(s) _wcslwr((wchar_t *)(s))
57 #define struprW(s) _wcsupr((wchar_t *)(s))
58 #define sprintfW swprintf
59 #define vsprintfW vswprintf
60 #define snprintfW _snwprintf
61 #define vsnprintfW _vsnwprintf
62 #define isprintW iswprint
63
64 static __inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
65 {
66 const WCHAR *end;
67 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)ptr;
68 return NULL;
69 }
70
71 static __inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
72 {
73 const WCHAR *end, *ret = NULL;
74 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = ptr;
75 return (WCHAR *)ret;
76 }
77
78 #endif