[fpc-devel] Controlling the output of the widestring manager

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Dec 3 15:17:05 CET 2007


On 03 Dec 2007, at 08:44, Florian Klaempfl wrote:

> Making such tests is not easy because they depend on the system  
> locale.
> Using only latin characters make it work on all systems but with latin
> only also the default implemenation works and renders the test  
> useless.
> Using non-latin characters might break because the locale of the test
> system isn't known. Maybe testing the locale in the tests and abort  
> with
> a warning but with no error if the test is run on a non
> 8859-1/utf-8/cp1250 system might be a way to go.

You can make tests for this which work in all locales (although they  
obviously can't test characters which aren't supported by the used  
locale), it's just a bit more work. E.g.

{$codepage utf-8}
uses
  {$ifdef unix}
  cwstring,
  {$endif}
   sysutils;

var
   s: ansistring;
   w1,w2,w3: widestring;
   i: longint;
begin
   w:='éèà';
   w2:='ÉÈÀ';
   s:=w;
   w:=AnsiUpperCase(s);
   { filter out unsupported characters }
   for i:=1 to length(w) do
     if w[i]='?' then
       w2[i]:='?';
   if w <> w2 then
     halt(1);
end.


Jonas


More information about the fpc-devel mailing list