Delphi WinAPI CompareString 和 CompareStringEx 比较两个标识符指定的两个字符串函数
Delphi WinAPI CompareString 和 CompareStringEx 比较两个标识符指定的两个字符串函数
1、CompareString
函数原型:
1 2 3 4 5 6 7 8 | int CompareString( LCID Locale, DWORD dwCmpFlags, LPCTSTR lpString1, int cchCount1, LPCTSTR lpString2, int cchCount2 ); |
参数:
- Locale
- LOCALE_CUSTOM_DEFAULT
- LOCALE_CUSTOM_UI_DEFAULT
- LOCALE_CUSTOM_UNSPECIFIED
- LOCALE_INVARIANT
- LOCALE_SYSTEM_DEFAULT
- LOCALE_USER_DEFAULT
- dwCmpFlags //指示函数如何比较两个字符串的标志。lpString1 //指向要比较的第一个字符串的指针。
- LINGUISTIC_IGNORECASE //忽略大小写
- LINGUISTIC_IGNOREDIACRITIC //忽略非空字符,忽略大小写
- NORM_IGNORECASE // Ignore case. For many scripts (notably Latin scripts), NORM_IGNORECASE coincides with LINGUISTIC_IGNORECASE.
- Note NORM_IGNORECASE //ignores any tertiary distinction, whether it is actually linguistic case or not. For example, in Arabic and Indic scripts, this distinguishes alternate forms of a character, but the differences do not correspond to linguistic case. LINGUISTIC_IGNORECASE causes the function to ignore only actual linguistic casing, instead of ignoring the third sorting weight.
- Note With this flag set, the function ignores the distinction between the wide and narrow forms of the CJK compatibility characters.
- NORM_IGNOREKANATYPE //Do not differentiate between hiragana and katakana characters. Corresponding hiragana and katakana characters compare as equal.
- NORM_IGNORENONSPACE //Ignore nonspacing characters. For many scripts (notably Latin scripts), NORM_IGNORENONSPACE coincides with LINGUISTIC_IGNOREDIACRITIC.
- Note NORM_IGNORENONSPACE //ignores any secondary distinction, whether it is a diacritic or not. Scripts for Korean, Japanese, Chinese, and Indic languages, among others, use this distinction for purposes other than diacritics. LINGUISTIC_IGNOREDIACRITIC causes the function to ignore only actual diacritics, instead of ignoring the second sorting weight.
- Note NORM_IGNORENONSPACE only has an effect for locales in which accented characters are sorted in a second pass from main characters. Normally all characters in the string are first compared without regard to accents and, if the strings are equal, a second pass over the strings is performed to compare accents. This flag causes the second pass to not be performed. For locales that sort accented characters in the first pass, this flag has no effect.
- NORM_IGNORESYMBOLS //Ignore symbols and punctuation.
- NORM_IGNOREWIDTH //Ignore the difference between half-width and full-width characters, for example, C a t == cat. The full-width form is a formatting distinction used in Chinese and Japanese scripts.
- NORM_LINGUISTIC_CASING //Use the default linguistic rules for casing, instead of file system rules. Note that most scenarios for CompareStringEx use this flag. This flag does not have to be used when your application calls CompareStringOrdinal.
- SORT_DIGITSASNUMBERS //Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10".
- SORT_STRINGSORT //Treat punctuation the same as symbols.
- cchCount1 //lpString1指示的字符串长度,不包括终止的空字符。
- lpString2 //指向要比较的第二个字符串的指针。
- cchCount2 //lpString2指示的字符串长度,不包括终止的空字符。
返回值:
- 如果成功,则返回以下值之一。为了保持比较字符串的C运行时惯例,可以从非零返回值中减去值2。那么,<0,==0,and>0的含义与C运行时是一致的。
- CSTR小于。lpString1指示的字符串的词法值小于lpString2指示的字符串。
- CSTR_相等。lpString1表示的字符串在词法值上与lpString2表示的字符串等效。这两个字符串在排序时是等价的,但不一定完全相同。
- 强制大于。lpString1指示的字符串的词法值大于lpString2指示的字符串。
- 如果函数不成功,则返回0。
2、CompareStringEx
函数原型:
1 2 3 4 5 6 7 8 9 10 11 | int CompareStringEx( LPCWSTR lpLocaleName, DWORD dwCmpFlags, _In_NLS_string_(cchCount1)LPCWCH lpString1, int cchCount1, _In_NLS_string_(cchCount2)LPCWCH lpString2, int cchCount2, LPNLSVERSIONINFO lpVersionInformation, LPVOID lpReserved, LPARAM lParam ); |
创建时间:2020.08.27 更新时间:
博客园 滔Roy https://www.cnblogs.com/guorongtao 希望内容对你有所帮助,谢谢!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
2019-08-27 (一)CGI (通用网关接口) 简介