Hooch
Hooch

Reputation: 29683

C++ , winapi Compare two WCHAR * strings

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*.

Upvotes: 5

Views: 24303

Answers (4)

i486
i486

Reputation: 6563

There is lstrcmpi function in Win32 API which works with LPCTSTR instead of const char *. Don't know why it is not popular - I use it since 1994 (mostly lstrcmp without "i").

Upvotes: 0

Matthew
Matthew

Reputation: 25763

For case sensitive comparison, look at wcscmp

For case insensitive comparison, look at _wcsicmp

Upvotes: 18

Thomas Russell
Thomas Russell

Reputation: 5980

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

Upvotes: 2

Constantinius
Constantinius

Reputation: 35069

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

For case insensitive comparison use wcscasecmp.

Upvotes: 2

Related Questions