开发者

Delphi - Differences between CompareStr and CompareString

开发者 https://www.devze.com 2022-12-23 23:31 出处:网络
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?

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 a开发者_StackOverflow中文版vailable comparison flags? Is one consequently faster than the other?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消