Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-10

String collating

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Honza

Hi all,

can anybody please comment on the following?

Bellow is a simple function, returning "M9,MD,P6". ____________________________

function F: String;
begin
  with TStringList.Create do
    try
      Sorted := True;
      Add('P6');
      Add('M9');
      Add('MD');
      Result := CommaText;
    finally
      Free;
    end;
end;
____________________________

It does so in a console program, but if invoked from within a GUI app, the result is "MD,M9,P6" (you can find the sources for both variants in the attached archive) on my system (Ubuntu 8.04.1):

Linux mypc 2.6.24-21-generic #1 SMP Mon Aug 25 17:32:09 UTC 2008 i686 GNU/Linux LANG=cs_CZ.UTF-8
GDM_LANG=cs_CZ.UTF-8
FPC SVN revision 11845
Lazarus SVN revision 16831

I've traced the execution of TStringList.Add downto calling strcoll() from libc (on rtl/unix/cwstring.pp line 578) which - to my surprise - returns opposite signed results in the console and gui variants for the same compare pair "MD" and "M9". There is possibly some difference in the initialization of an application which causes this behaviour
and which also could be bound to my non English locale. Or it may be a bug somewhere in the libc/RTL/LCL? (of course it may be also an error between my seat and keyboard :-)
I was not yet able to find out if this is a bug at all or just the intended string collating of a Czech locale.

Any feedback would be appreciated.

BFLM

Reply by email