tag:blogger.com,1999:blog-4434108347727659251.post3612367926737235060..comments2022-06-29T08:53:03.580+02:00Comments on Compas Pascal: Do not set TStringList.sorted:=True with default comparisonUnknownnoreply@blogger.comBlogger14125tag:blogger.com,1999:blog-4434108347727659251.post-1944600420411891112009-06-15T19:14:32.195+02:002009-06-15T19:14:32.195+02:00Add Brazilian Portuguese locale to the list. Every...Add Brazilian Portuguese locale to the list. Every time I sort the Dag's list, I get a different result.<br />Damned Windows.fabricioaraujo_rjhttps://www.blogger.com/profile/01066634181074390410noreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-8348108752440744612009-06-15T19:08:34.525+02:002009-06-15T19:08:34.525+02:00Comparison uses weight a symbol.
http://unicode.or...Comparison uses weight a symbol.<br />http://unicode.org/reports/tr10/<br />Any one of parameter of the functions CompareString does not switch off use all of weight symbols.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-89863382037304155192009-06-15T08:48:45.878+02:002009-06-15T08:48:45.878+02:00I will be looking into this. Do you happen to have...I will be looking into this. Do you happen to have the source code for the testcase or a QC bug report? <br /><br />Thanks!Holger Flickhttp://flickdotnet.denoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-63547323255234215922009-06-15T08:48:20.899+02:002009-06-15T08:48:20.899+02:00'SWE'<'SVK' is also true for Da...'SWE'<'SVK' is also true for Danish locale, but that isn't a problem.Lars Dhttps://www.blogger.com/profile/06217303713945608384noreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-36542361361430554252009-06-15T08:27:55.151+02:002009-06-15T08:27:55.151+02:00Another example is the Finnish (Finland) locale (t...Another example is the Finnish (Finland) locale (tested under Windows 2000, probably also true for XP), which somehow decides that sorting the strings SVK and SWE will give : SWE followed by SVK. Olivier BeltramiQ++Studiohttps://www.blogger.com/profile/00155517586451821711noreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-81947947991790772992009-06-15T07:42:01.540+02:002009-06-15T07:42:01.540+02:00Long time issue indeed.
We've been patching t...Long time issue indeed.<br /><br />We've been patching the RTL here for years (redirecting CompareText to a custom implementation) to avoid that problem and its variants .Erichttps://www.blogger.com/profile/05912696305224378407noreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-2388277251105711242009-06-15T04:45:44.303+02:002009-06-15T04:45:44.303+02:00This long ago known problem for RUSSIAN code poage...This long ago known problem for RUSSIAN code poage. In ansi version RTL I happened to to write the hook of winapi functions CompareStringA, lstrcmpA, lstrcmpiA. The table of symbols for comparisons I took from ORACLE. Bad that no possibility to adjust this in RTL.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-53305131171474685142009-06-15T04:13:43.002+02:002009-06-15T04:13:43.002+02:00Note: This isn't limited to D2009.
TStringLis...Note: This <b>isn't</b> limited to D2009.<br /><br />TStringList.IndexOf()has used TStringList.Find on sorted lists for a long time (D6 at least, and if my memory is correct before that)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-73524811741537104442009-06-14T18:48:05.568+02:002009-06-14T18:48:05.568+02:00The discovery of the undesirable tstringlist sorti...The discovery of the undesirable tstringlist sorting/searching behavior was made by programmers at Semaphore Corporation (semaphorecorp.com) as a result of working with US Postal Service data files. While building a tstringlist of over 160,000 maximum and minimum apartment numbers in the country, it was found that apartment 59-A appeared to be a special case: it failed to be located by .IndexOfAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-64609896683747153512009-06-14T12:18:54.331+02:002009-06-14T12:18:54.331+02:00if CompareStr is used for both sorting and IndexOf...if CompareStr is used for both sorting and IndexOf and it is stable (aka produces the same ordering). It should not matter to the binary search.<br /><br />I've looked into TStringList and those use the same function for comparison. So the only possible explanations is that CompareStr in these cases is not stable which may mean a system bug indeed.alexhttp://alex.ciobanu.orgnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-12229295943791904882009-06-14T12:14:31.631+02:002009-06-14T12:14:31.631+02:00Adding the SORT_STRINGSORT flag to the CompareStri...Adding the SORT_STRINGSORT flag to the CompareString() call works for this case but might break other cases.Andreas Hausladennoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-42523860283543217632009-06-14T12:07:50.255+02:002009-06-14T12:07:50.255+02:00Binary lookup requires that there is a predefined ...Binary lookup requires that there is a predefined order, so that:<br /><br />if A < B < C, we can assume, that A < C<br /><br />But the bug in Windows means that CompareStr does not comply with this requirement. Therefore, the default string comparison algorithm in TStringList, which uses the Windows API, is not suitable for .IndexOf() or .Find() on sorted lists.Lars Dhttps://www.blogger.com/profile/06217303713945608384noreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-18807660224865773782009-06-14T11:51:59.217+02:002009-06-14T11:51:59.217+02:00I thought each locale defines own rules about this...I thought each locale defines own rules about this. For example 'a' > 'A' normally but in some locales 'a' < 'A'.<br /><br />It is also not clear to me why is TStringList not working. Since if the same CompareStr is used for sorting and for lookup, the rules are the same and thus the search should also work.<br /><br />Weird ..alexhttp://alex.ciobanu.orgnoreply@blogger.comtag:blogger.com,1999:blog-4434108347727659251.post-77067394783967132992009-06-14T11:44:54.354+02:002009-06-14T11:44:54.354+02:00Same behaviour under Vista-32/SP1. A DOS windows, ...Same behaviour under Vista-32/SP1. A DOS windows, using 'dir /on' gives this<br /><br />59A.txt<br />-59-A.txt<br />5-9A.txt<br />59-A.txt<br /><br />whereas the 'sort' command gives this:<br /><br />-59-A.txt<br />5-9A.txt<br />59-A.txt<br />59A.txt<br /><br />which is correct. So it seems that 'sort' does its own sorting and 'dir' is using Windows.Dag Hovdennoreply@blogger.com