Does anybody know how to use wcsstr
with no case sensitivity on C? If this important I will use it in kernel driver.
If you're programming under Windows you can use the StrStrI()
function.
You can't use it in a kernel driver so you have to write it by your own. In that example toupper()
is used and should be replace with RtlUpcaseUnicodeChar
(as pointed out by Rup). To summarize you need something like this:
char *stristr(const wchar_t *String, const wchar_t *Pattern)
{
wchar_t *pptr, *sptr, *start;
for (start = (wchar_t *)String; *start != NUL; ++start)
{
while (((*start!=NUL) && (RtlUpcaseUnicodeChar(*start)
!= RtlUpcaseUnicodeChar(*Pattern))))
{
++start;
}
if (NUL == *start)
return NULL;
pptr = (wchar_t *)Pattern;
sptr = (wchar_t *)start;
while (RtlUpcaseUnicodeChar(*sptr) == RtlUpcaseUnicodeChar(*pptr))
{
sptr++;
pptr++;
if (NUL == *pptr)
return (start);
}
}
return NULL;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With