On Tue, 8 Sep 2020 20:27:20 +0200
Jonas Maebe via fpc-pascal <[email protected]> wrote:
> On 07/09/2020 08:51, LacaK via fpc-pascal wrote:
>
> > attached simple Lazarus compilable project (one Form).
> >
> > ...
> > type
> > String1250 = type AnsiString(1250);
> >
> > const
> > c2: AnsiString = 'áéíóčž';
> > c3: WideString = 'áéíóčž';
> > c4: String1250 = 'áéíóčž';
> >
> > { TForm1 }
> >
> > procedure TForm1.FormShow(Sender: TObject);
> > begin
> > label1.Caption:='áéíóčž'; // FAIL
> > label2.Caption:=c2; // FAIL
label2.Caption:='a'+c2; // OK
> > label3.Caption:=c3; // OK
> > label4.Caption:=c4; // FAIL
> > end;
Reason is that LCL TLabel.Caption expects UTF-8.
You can use
label2.Caption:=WinCPToUTF8(c2); // from unit LazUTF8
Maybe SetCaption could check if passed string is not CP_ACP and do a
conversion.
Mattias
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal