Delphi - CompareStr 和 CompareString 之间的差异

发布于 2024-08-26 10:25:19 字数 197 浏览 2 评论 0原文

我希望有人能为我阐明这一点: 在 Delphi 2009 中,CompareStr(在 SysUtils 中定义)和 CompareString(来自 Windows API)函数之间有什么区别?

两者都允许您指定要使用的区域设置,由于可用的比较标志,Windows 是否更“完整”?因此其中一个比另一个更快吗?

I'm hoping someone can shed some light on this for me:
What are the differences, in Delphi 2009, between the CompareStr (defined in SysUtils) and CompareString (from Windows API) functions?

Both let you specify the locale to be used, is the Windows one simply more "complete", due to the available comparison flags? Is one consequently faster than the other?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀お生予夺 2024-09-02 10:25:19

CompareString 使用区域设置信息,以便将 ae 和 æ 之类的内容视为匹配项,并且排序适合于地理区域。

CompareStr('', loInvariantLocale) 只是对字符串中的字符进行逐字节比较。 CompareStr('', loUserLocale) 在内部调用 CompareString,因此除了 CompareString 可以接受的附加标志之外,它们是相同的。它也是内联的,因此您不应该看到它与直接调用 CompareString 之间的速度有任何差异。

CompareString uses locale information so that things like ae and æ are treated as matches, and sorting is appropriate for the geographical region.

CompareStr('', loInvariantLocale) is just a byte-by-byte comparison of the characters in a string. CompareStr('', loUserLocale) calls CompareString internally, so they're identical, other than the additional flags that CompareString can accept. It's also inlined, so you shouldn't see any difference in speed between it and calling CompareString directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文