2 * NTDLL wide-char functions
4 * Copyright 2000 Alexandre Julliard
16 #include "wine/unicode.h"
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(ntdll
);
23 /*********************************************************************
24 * NTDLL__wcsicmp (NTDLL)
26 INT __cdecl
NTDLL__wcsicmp( LPCWSTR str1
, LPCWSTR str2
)
28 return strcmpiW( str1
, str2
);
32 /*********************************************************************
33 * NTDLL__wcslwr (NTDLL)
35 LPWSTR __cdecl
NTDLL__wcslwr( LPWSTR str
)
37 return strlwrW( str
);
41 /*********************************************************************
42 * NTDLL__wcsnicmp (NTDLL)
44 INT __cdecl
NTDLL__wcsnicmp( LPCWSTR str1
, LPCWSTR str2
, INT n
)
46 return strncmpiW( str1
, str2
, n
);
50 /*********************************************************************
51 * NTDLL__wcsupr (NTDLL)
53 LPWSTR __cdecl
NTDLL__wcsupr( LPWSTR str
)
55 return struprW( str
);
59 /*********************************************************************
60 * NTDLL_towlower (NTDLL)
62 WCHAR __cdecl
NTDLL_towlower( WCHAR ch
)
68 /*********************************************************************
69 * NTDLL_towupper (NTDLL)
71 WCHAR __cdecl
NTDLL_towupper( WCHAR ch
)
77 /***********************************************************************
78 * NTDLL_wcscat (NTDLL)
80 LPWSTR __cdecl
NTDLL_wcscat( LPWSTR dst
, LPCWSTR src
)
82 return strcatW( dst
, src
);
86 /*********************************************************************
87 * NTDLL_wcschr (NTDLL)
89 LPWSTR __cdecl
NTDLL_wcschr( LPCWSTR str
, WCHAR ch
)
91 return strchrW( str
, ch
);
95 /*********************************************************************
96 * NTDLL_wcscmp (NTDLL)
98 INT __cdecl
NTDLL_wcscmp( LPCWSTR str1
, LPCWSTR str2
)
100 return strcmpW( str1
, str2
);
104 /***********************************************************************
105 * NTDLL_wcscpy (NTDLL)
107 LPWSTR __cdecl
NTDLL_wcscpy( LPWSTR dst
, LPCWSTR src
)
109 return strcpyW( dst
, src
);
113 /*********************************************************************
114 * NTDLL_wcscspn (NTDLL)
116 INT __cdecl
NTDLL_wcscspn( LPCWSTR str
, LPCWSTR reject
)
122 while (*p
&& (*p
!= *str
)) p
++;
130 /***********************************************************************
131 * NTDLL_wcslen (NTDLL)
133 INT __cdecl
NTDLL_wcslen( LPCWSTR str
)
135 return strlenW( str
);
139 /*********************************************************************
140 * NTDLL_wcsncat (NTDLL)
142 LPWSTR __cdecl
NTDLL_wcsncat( LPWSTR s1
, LPCWSTR s2
, INT n
)
146 while (n
-- > 0) if (!(*s1
++ = *s2
++)) return ret
;
152 /*********************************************************************
153 * NTDLL_wcsncmp (NTDLL)
155 INT __cdecl
NTDLL_wcsncmp( LPCWSTR str1
, LPCWSTR str2
, INT n
)
157 return strncmpW( str1
, str2
, n
);
161 /*********************************************************************
162 * NTDLL_wcsncpy (NTDLL)
164 LPWSTR __cdecl
NTDLL_wcsncpy( LPWSTR s1
, LPCWSTR s2
, INT n
)
166 return strncpyW( s1
, s2
, n
);
170 /*********************************************************************
171 * NTDLL_wcspbrk (NTDLL)
173 LPWSTR __cdecl
NTDLL_wcspbrk( LPCWSTR str
, LPCWSTR accept
)
178 for (p
= accept
; *p
; p
++) if (*p
== *str
) return (LPWSTR
)str
;
185 /*********************************************************************
186 * NTDLL_wcsrchr (NTDLL)
188 LPWSTR __cdecl
NTDLL_wcsrchr( LPWSTR str
, WCHAR ch
)
193 if (*str
== ch
) last
= str
;
200 /*********************************************************************
201 * NTDLL_wcsspn (NTDLL)
203 INT __cdecl
NTDLL_wcsspn( LPCWSTR str
, LPCWSTR accept
)
209 while (*p
&& (*p
!= *str
)) p
++;
217 /*********************************************************************
218 * NTDLL_wcsstr (NTDLL)
220 LPWSTR __cdecl
NTDLL_wcsstr( LPCWSTR str
, LPCWSTR sub
)
222 return strstrW( str
, sub
);
226 /*********************************************************************
227 * NTDLL_wcstok (NTDLL)
229 LPWSTR __cdecl
NTDLL_wcstok( LPWSTR str
, LPCWSTR delim
)
231 static LPWSTR next
= NULL
;
235 if (!(str
= next
)) return NULL
;
237 while (*str
&& NTDLL_wcschr( delim
, *str
)) str
++;
238 if (!*str
) return NULL
;
240 while (*str
&& !NTDLL_wcschr( delim
, *str
)) str
++;
241 if (*str
) *str
++ = 0;
247 /*********************************************************************
248 * NTDLL_wcstombs (NTDLL)
250 INT __cdecl
NTDLL_wcstombs( LPSTR dst
, LPCWSTR src
, INT n
)
253 if (n
<= 0) return 0;
254 ret
= WideCharToMultiByte( CP_ACP
, 0, src
, -1, dst
, dst
? n
: 0, NULL
, NULL
);
255 if (!ret
) return n
; /* overflow */
256 return ret
- 1; /* do not count terminating NULL */
260 /*********************************************************************
261 * NTDLL_mbstowcs (NTDLL)
263 INT __cdecl
NTDLL_mbstowcs( LPWSTR dst
, LPCSTR src
, INT n
)
266 if (n
<= 0) return 0;
267 ret
= MultiByteToWideChar( CP_ACP
, 0, src
, -1, dst
, dst
? n
: 0 );
268 if (!ret
) return n
; /* overflow */
269 return ret
- 1; /* do not count terminating NULL */
273 /*********************************************************************
275 * Like strtol, but for wide character strings.
277 INT __cdecl
NTDLL_wcstol(LPWSTR s
,LPWSTR
*end
,INT base
)
279 LPSTR sA
= HEAP_strdupWtoA(GetProcessHeap(),0,s
),endA
;
280 INT ret
= strtol(sA
,&endA
,base
);
282 HeapFree(GetProcessHeap(),0,sA
);
283 if (end
) *end
= s
+(endA
-sA
); /* pointer magic checked. */
288 /*********************************************************************
289 * NTDLL_iswctype (NTDLL)
291 INT __cdecl
NTDLL_iswctype( WCHAR wc
, WCHAR wct
)
293 return (get_char_typeW(wc
) & 0xfff) & wct
;
297 /*********************************************************************
298 * NTDLL_iswalpha (NTDLL)
300 INT __cdecl
NTDLL_iswalpha( WCHAR wc
)
302 return get_char_typeW(wc
) & C1_ALPHA
;
306 /*********************************************************************
308 * Like _ultoa, but for wide character strings.
310 LPWSTR __cdecl
_ultow(ULONG value
, LPWSTR string
, INT radix
)
318 if (radix
> 36 || radix
<= 1)
321 while (v
|| tp
== tmp
)
328 *tp
++ = i
+ 'a' - 10;