[fpc-devel] String collating

Honza befelemepeseveze at gmail.com
Wed Oct 1 23:11:55 CEST 2008


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: question.tar.gz
Type: application/x-gzip
Size: 2532 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20081001/b7f0aa31/attachment.bin>


More information about the fpc-devel mailing list