简体   繁体   English

C ++,winapi比较两个WCHAR *字符串

[英]C++ , winapi Compare two WCHAR * strings

I want to compare two WCHAR* strings. 我想比较两个WCHAR*字符串。

How to do it? 怎么做?

PS I would like to ignore case while comparing. PS我想在比较时忽略大小写

I know you can use strcmpi but it id not working for WCHAR* . 我知道你可以使用strcmpi但它不能用于WCHAR*

For case sensitive comparison, look at wcscmp 对于区分大小写的比较,请查看wcscmp

For case insensitive comparison, look at _wcsicmp 对于不区分大小写的比较,请查看_wcsicmp

You have to use the WCHAR_t versions of strcmp . 您必须使用strcmpWCHAR_t版本。 You can find the definitions here . 您可以在此处找到定义。

For case insensitive comparison use wcscasecmp . 对于不区分大小写的比较,请使用wcscasecmp

Have you considered using StrCmpLogicalW()? 你考虑过使用StrCmpLogicalW()吗? Depending on your need that might be preferable to wcscmp. 根据您的需要,可能比wcscmp更可取。

There is lstrcmpi function in Win32 API which works with LPCTSTR instead of const char * . Win32 API中有lstrcmpi函数,它与LPCTSTR而不是const char * Don't know why it is not popular - I use it since 1994 (mostly lstrcmp without "i"). 不知道为什么它不受欢迎 - 我从1994年开始使用它(主要是没有“i”的lstrcmp )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM