views:

129

answers:

2

i'm using delphi 2009 to write an app that uses an Access database.

i noticed that MS Access' ORDER BY seems to be sorting international character sets like AnsiCompareText whereas throughout my app, i'm using SysUtils.CompareText( ).

Access' (Jet's) ORDER BY results (delphi AnsiCompareText( ) is the same)
  Nørmork
  Öster
  RAM

delphi CompareText( )
  Nørmork
  RAM
  Öster

which is the correct call i should be using for a comparison?

note: i am using USA English as my locale.

sorry, i don't know so much about this. there are many web sites that discuss related topics at length but i haven't seen a discussion about which is most appropriate.

thank you!

+2  A: 

Seems to me that the correct comparison is the one that gives the same results as your database, if only for consistency's sake. Use AnsiCompareText and then you won't have to worry about mismatching results.

Mason Wheeler
+6  A: 

CompareText does an ASCII comparision while AnsiCompareText uses the ANSI codepage (or in Delphi 2009+ the unicode table) to compare characters. So CompareText only works if you have plain English text.

Andreas Hausladen
i have thought the Ansi* calls were for MBCS and not for unicode.
X-Ray
The Ansi functions are Unicode as of Delphi 2009. (Didn't the readme mention that?) Compatibility of function names was deemed more important than strictly logical function names. Also see the new AnsiStrings unit, which has the old MBCS functions.
Rob Kennedy