C++ , winapi Compare two WCHAR * strings

21,058

Solution 1

For case sensitive comparison, look at wcscmp

For case insensitive comparison, look at _wcsicmp

Solution 2

You have to use the WCHAR_t versions of strcmp. You can find the definitions here.

For case insensitive comparison use wcscasecmp.

Solution 3

Have you considered using StrCmpLogicalW()? Depending on your need that might be preferable to wcscmp.

Share:
21,058
Hooch
Author by

Hooch

Updated on May 27, 2020

Comments

  • Hooch
    Hooch almost 4 years

    I want to compare two WCHAR* strings.

    How to do it?

    P.S. I would like to ignore case while comparing.

    I know you can use strcmpi but it id not working for WCHAR*.

  • Hooch
    Hooch over 12 years
    How to use it so that I can ignore case?
  • Hooch
    Hooch over 12 years
    Again, this is case sensitive.
  • Thomas Russell
    Thomas Russell over 12 years
    No, it's not, take a look at the MSDN page. :-)
  • Matthew
    Matthew almost 10 years
    @SoumyajitRoy I'm sure something exists, but this question was tagged winapi.
  • Ajay
    Ajay almost 7 years
    However, StrCmpLogicalW would care for prefix numbers in string.