English 中文(简体)
比较和排序 Unicode 文件名
原标题:Comparing and sorting Unicode filenames

使用Delphi 2007和TMS组件进行Unicode工具和界面处理(升级到Delphi 2009以支持Unicode不是一个选择)。

我正在将文件名列表存储在字符串列表(TTntStringList)中。它是经过排序的且不区分大小写。默认的排序程序使用CompareStringW(LOCALE_USER_DEFAULT,NORM_IGNORECASE,...)来比较字符串(查找也是如此)。然而,这是一个问题,因为这将把dummyss.txt与dummyß.txt(例如)视为相同,但在NTFS上,这样做是完全合法的,即它们被视为不同的名称。

我理解的是,在Vista及以上版本上,比较文件名的正确方法是使用CompareStringOrdinal。这正确吗?

在Vista之前的系统上,正确的方式是什么?我相信应该是CompareStringW(LOCALE_INVARIANT,...),但我不完全确定。

谢谢 (xiè xiè)

最佳回答

MSDN文章中的引用处理应用程序中的排序:

CompareStringOrdinal compares two Unicode strings to test for binary equality, as opposed to linguistic equality. Examples of such non-linguistic strings are NTFS file names, ...

比较标准要求Windowsista或之后。

编辑:是的,在Vista之前的Windows系统中,可以使用RtlCompareUnicodeString,它也被CompareStringOrdinal内部使用,并且自Windows NT起可用。

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签