WCSSTR不区分大小写

use*_*425 3 c windows driver case-insensitive

有人知道如何在wcsstr不区分大小写的情况下使用C吗?如果这个很重要,我将在内核驱动程序中使用它。

Adr*_*tti 5

如果您在Windows下编程,则可以使用该StrStrI()功能。

您不能在内核驱动程序中使用它,因此必须自己编写。在该示例toupper()中,应使用并且应将其替换为RtlUpcaseUnicodeChar(如Rup所指出的)。总结一下,您需要这样的东西:

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;
}
Run Code Online (Sandbox Code Playgroud)