C++ Builder 参考手册 ➙ System::Sysutils ➙ CompareStr
比较两个字符串,直接比较每个字节是否相同,或者使用当前的地区和语言,区分大小写。
头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:
int __fastcall CompareStr(const System::UnicodeString S1, const System::UnicodeString S2);
int __fastcall CompareStr(const System::UnicodeString S1, const System::UnicodeString S2, TLocaleOptions LocaleOptions);
参数:
- S1:要比较的字符串1,UnicodeString 类型;
- S2:要比较的字符串2,UnicodeString 类型;
- LocaleOptions:是否使用当前用户的地区和语言:
• loInvariantLocale:和语言无关,直接比较字符串里面每个编码单元 (char16_t) 的大小;
• loUserLocale:使用当前用户的地区和语言;
返回值:
- 0: S1==S2
- >0: S1>S2
- <0: S1<S2
- 如果没有 LocaleOptions 参数,认为是 loInvariantLocale 和语言无关,直接比较字符串里面每个编码单元的大小;
- 如果 LocaleOptions 参数等于 loUserLocale,使用当前用户的地区和语言,此时和 System::Sysutils::AnsiCompareStr 的比较结果相同。
相关:
- System::Sysutils::TLocaleOptions
- System::Sysutils::AnsiCompareStr
- System::Sysutils::AnsiCompareFileName
- System::Sysutils::AnsiCompareText
- System::Sysutils::AnsiStrComp
- System::Sysutils::AnsiStrIComp
- System::Sysutils::AnsiStrLComp
- System::Sysutils::AnsiStrLIComp
- System::Sysutils::CompareMem
- System::Sysutils::CompareStr
- System::Sysutils::CompareText
- System::Sysutils::StrComp
- System::Sysutils::StrIComp
- System::Sysutils::StrLComp
- System::Sysutils::StrLIComp
- System::Sysutils::WideCompareStr
- System::Sysutils::WideCompareText
- System::Sysutils
- strcmp, _strcmp, _fstrcmp, _tcscmp, wcscmp
- strncmp, _fstrncmp, _tcsncmp, _tcsnccmp, wcsncmp
- stricmp, _stricmp, _fstricmp, strcmpi, _strcmpi, _tcsicmp, _tcscmpi, _wcsicmp, wcscmpi, _wcscmpi
- strnicmp, _strnicmp, _fstrnicmp, strncmpi, _tcsnicmp, _tcsncicmp, _tcsncmpi, _wcsnicmp, wcsncmpi, _wcsncmpi
- <cstring>
C++ Builder 参考手册 ➙ System::Sysutils ➙ CompareStr