3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ntdll/string/wstring.c
6 * PURPOSE: Wide string functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
10 * 1998/12/04 RJJ Cleaned up and added i386 def checks
13 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
19 /* FUNCTIONS *****************************************************************/
21 int _wcsicmp (const wchar_t* cs, const wchar_t * ct)
23 while (towlower(*cs) == towlower(*ct))
30 return towlower(*cs) - towlower(*ct);
34 wchar_t *_wcslwr (wchar_t *x)
46 int _wcsnicmp (const wchar_t * cs, const wchar_t * ct, size_t count)
51 if (towupper(*cs) != towupper(*ct++))
52 return towupper(*cs) - towupper(*--ct);
55 } while (--count != 0);
60 wchar_t *_wcsupr(wchar_t *x)
72 wchar_t *wcscat (wchar_t *dest, const wchar_t *src)
76 for (j = 0; dest[j] != 0; j++)
78 for (i = 0; src[i] != 0; i++)
87 wchar_t *wcschr (const wchar_t *str, wchar_t ch)
89 while ((*str) != ((wchar_t) 0))
93 return (wchar_t *)str;
101 int wcscmp(const wchar_t *cs, const wchar_t *ct)
103 while (*cs != '\0' && *ct != '\0' && *cs == *ct)
111 wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
125 size_t wcscspn(const wchar_t *str,const wchar_t *reject)
141 return s-str; /* nr of wchars */
145 size_t wcslen(const wchar_t *s)
147 unsigned int len = 0;
157 wchar_t *wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
161 for (j = 0; dest[j] != 0; j++)
163 for (i = 0; i < count; i++)
165 dest[j + i] = src[i];
177 int wcsncmp(const wchar_t * cs,const wchar_t * ct,size_t count)
179 while ((*cs) == (*ct) && count > 0)
187 return (*cs) - (*ct);
191 wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
195 for (i = 0; i < count; i++)
208 wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2)
210 const wchar_t *scanp;
213 while ((c = *s1++) != 0)
215 for (scanp = s2; (sc = *scanp++) != 0;)
218 return (wchar_t *)(--s1);
225 wchar_t * wcsrchr(const wchar_t *str, wchar_t ch)
227 unsigned int len = 0;
228 while (str[len] != ((wchar_t)0))
233 for (; len > 0; len--)
237 return (wchar_t *) &str[len - 1];
245 size_t wcsspn(const wchar_t *str,const wchar_t *accept)
261 return s-str; /* nr of wchars */
265 wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
275 while (*y && *c && *y==*c) {