3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/rtl/wstring.c
6 * PURPOSE: Wide string functions
7 * PROGRAMMER: David Welch (welch@cwcom.net)
10 * 1998/12/04 RJJ Cleaned up and added i386 def checks.
11 * 1999/07/29 ekohl Added missing functions.
14 /* INCLUDES *****************************************************************/
16 #include <ddk/ntddk.h>
19 #include <internal/debug.h>
21 /* FUNCTIONS *****************************************************************/
23 int _wcsicmp (const wchar_t* cs, const wchar_t* ct)
25 while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
35 wchar_t *_wcslwr (wchar_t *x)
48 int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count)
53 if (towupper(*cs) != towupper(*ct++))
54 return towupper(*cs) - towupper(*--ct);
57 } while (--count != 0);
62 wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
64 wchar_t *t = wsToFill;
66 while( *wsToFill != 0 && i < (int) sizeMaxFill)
76 wchar_t *_wcsrev(wchar_t *s)
95 wchar_t *_wcsupr(wchar_t *x)
107 #endif /* LIBCAPTIVE */
109 wchar_t * wcscat(wchar_t *dest, const wchar_t *src)
113 for (j = 0; dest[j] != 0; j++)
115 for (i = 0; src[i] != 0; i++)
117 dest[j + i] = src[i];
124 wchar_t * wcschr(const wchar_t *str, wchar_t ch)
126 while ((*str) != ((wchar_t) 0))
130 return (wchar_t *) str;
138 int wcscmp(const wchar_t *cs, const wchar_t *ct)
140 while (*cs != '\0' && *ct != '\0' && *cs == *ct)
148 wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
151 /* Never dump 'str1' here as it can crash due to unitialized memory access (no end-terminator). */
152 DPRINT("wcscpy(str1 <undef>, str2 %S)\n",str2);
165 size_t wcscspn(const wchar_t *str,const wchar_t *reject)
181 return s-str; /* nr of wchars */
184 #endif /* LIBCAPTIVE */
186 size_t wcslen(const wchar_t *s)
188 unsigned int len = 0;
200 wchar_t * wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
204 for (j = 0; dest[j] != 0; j++)
206 for (i = 0; i < count; i++)
208 dest[j + i] = src[i];
220 int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
222 while (*cs != '\0' && *ct != '\0' && *cs == *ct && --count)
231 wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
235 for (i = 0; i < count; i++)
247 #endif /* LIBCAPTIVE */
249 wchar_t *wcsrchr(const wchar_t *str, wchar_t ch)
251 unsigned int len = 0;
252 while (str[len] != ((wchar_t)0))
257 for (; len > 0; len--)
261 return (wchar_t *) &str[len - 1];
270 size_t wcsspn(const wchar_t *str,const wchar_t *accept)
288 return s-str; /* nr of wchars */
292 wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
304 while (*y && *c && *y==*c)
317 #endif /* LIBCAPTIVE */