ImportTool do not work in Czech locale

Please, consider to change NoTerminals comparsion code. AnsiCompareText do no work with Czech locale. For example IntProcHeading and intprocheading are different strings and AnsiCompareText do not return 0.This code work in Czech locale:

function TNoTerminals.IndexOf(IdS:string):integer;
   for result:=0 to Count-1 do
      if AnsiLowerCase(TNoTerminal(Items[result]).IdS)=AnsiLowerCase(IdS) then Exit;

I don't understand how AnsiLowerCase works and AnsiCompareText is not. Both rely on low-level Windows API functions. Can you give some concrete example?

The only example you provided is not sure. The following code shows "0":

procedure TForm1.Button1Click(Sender: TObject);
  ShowMessage(AnsiCompareText('IntProcHeading', 'intprocheading').ToString);

On my windows, your example shows -1.

This is a Delphi/Windows bug then?

No, this is misunderstanding what AnsiCompareText does. It calls CompareStringW from winapi ( Compares two character strings, for a locale specified by identifier.)
Comapreflags =NORM_IGNORECASE. And result in win api help: "The string indicated by lpString1 is equivalent in lexical value to the string indicated by lpString2."

This function is very locale specific and has nothing common with AnsiLowerCase or AnsiUpperCase.

For example:
-'IntProcHeading' and 'intprocheading' returns -1
-'IntProcheading' and 'intprocheading' returns 0
-'IntprocHeading' and 'intprocheading' returns -1
Do not use lexical functions in these comparsions.

Are those results returning -1 because your computer is configured to use Czech locale? Because they all return 0 to me.

Is this something specific to Czech language? How is IntProcHeading different from intprocheading?

Yes it's because my computer uses Czech Locale. I think it means something if there are three capital letter when sorting these foreign words. I do not know exactly reason, but Czech sorting rules are little weird in common. :roll_eyes:

Ok, thanks for the explanation. We have made the modification in the source code as you suggested, next version will include it. In the meanwhile you can of course keep using your modified code.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.