Add a library "host_wcsfuncs" with implementations for UTF-16 string functions needed...
[reactos.git] / reactos / lib / host / wcsfuncs / wcsfuncs.c
1 /*
2 PROJECT: ReactOS
3 LICENSE: GPL v2 or any later version
4 FILE: lib/host/wcsfuncs/wcsfuncs.c
5 PURPOSE: Reimplemented wide-character string functions for host tools (to be independent of the host wchar_t size)
6 COPYRIGHT: Copyright 2008 Colin Finck <mail@colinfinck.de>
7 */
8
9 #include <host/typedefs.h>
10
11 /* Function implementations */
12 SIZE_T utf16_wcslen(PCWSTR str)
13 {
14 SIZE_T i;
15
16 for(i = 0; str[i]; i++);
17
18 return i;
19 }
20
21 PWSTR utf16_wcschr(PWSTR str, WCHAR c)
22 {
23 SIZE_T i;
24
25 for(i = 0; str[i] && str[i] != c; i++);
26
27 if(str[i])
28 return &str[i];
29 else
30 return NULL;
31 }
32
33 INT utf16_wcsncmp(PCWSTR string1, PCWSTR string2, size_t count)
34 {
35 while(count--)
36 {
37 if(*string1 != *string2)
38 return 1;
39
40 if(*string1 == 0)
41 return 0;
42
43 string1++;
44 string2++;
45 }
46
47 return 0;
48 }