xref: /reactos/sdk/include/reactos/wine/unicode.h (revision 84344399)
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 #if (_WIN32_WINNT < _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
28 /* msvcrt versions incompatibilities */
29 #define _swprintf(s,f,...) _snwprintf((s),MAXLONG,(f),##__VA_ARGS__)
30 #define _vswprintf(s,f,v) _vsnwprintf((s),MAXLONG,(f),(v))
31 #endif
32 
33 #define memicmpW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
34 #define strlenW(s) wcslen((s))
35 #define strcpyW(d,s) wcscpy((d),(s))
36 #define strcatW(d,s) wcscat((d),(s))
37 #define strcspnW(d,s) wcscspn((d),(s))
38 #define strstrW(d,s) wcsstr((d),(s))
39 #define strtolW(s,e,b) wcstol((s),(e),(b))
40 #define strchrW(s,c) wcschr((s),(c))
41 #define strrchrW(s,c) wcsrchr((s),(c))
42 #define strncmpW(s1,s2,n) wcsncmp((s1),(s2),(n))
43 #define strncpyW(s1,s2,n) wcsncpy((s1),(s2),(n))
44 #define strcmpW(s1,s2) wcscmp((s1),(s2))
45 #define strcmpiW(s1,s2) _wcsicmp((s1),(s2))
46 #define strncmpiW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
47 #define strtoulW(s1,s2,b) wcstoul((s1),(s2),(b))
48 #define strspnW(str, accept) wcsspn((str),(accept))
49 #define strpbrkW(str, accept) wcspbrk((str),(accept))
50 #define tolowerW(n) towlower((n))
51 #define toupperW(n) towupper((n))
52 #define islowerW(n) iswlower((n))
53 #define isupperW(n) iswupper((n))
54 #define isalphaW(n) iswalpha((n))
55 #define isalnumW(n) iswalnum((n))
56 #define isdigitW(n) iswdigit((n))
57 #define isxdigitW(n) iswxdigit((n))
58 #define isspaceW(n) iswspace((n))
59 #define iscntrlW(n) iswcntrl((n))
60 #define atoiW(s) _wtoi((s))
61 #define atolW(s) _wtol((s))
62 #define strlwrW(s) _wcslwr((s))
63 #define struprW(s) _wcsupr((s))
64 #define sprintfW _swprintf
65 #define vsprintfW _vswprintf
66 #define snprintfW _snwprintf
67 #define vsnprintfW _vsnwprintf
68 #define isprintW iswprint
69 
70 static __inline unsigned short get_char_typeW( WCHAR ch )
71 {
72     extern const unsigned short wine_wctype_table[];
73     return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)];
74 }
75 
76 static __inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
77 {
78     const WCHAR *end;
79     for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)ptr;
80     return NULL;
81 }
82 
83 static __inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
84 {
85     const WCHAR *end, *ret = NULL;
86     for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = ptr;
87     return (WCHAR *)ret;
88 }
89 
90 #endif
91