[fpc-pascal] String literals and code page of .pas source file
Sven Barth
pascaldragon at googlemail.com
Tue Sep 8 23:28:31 CEST 2020
Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb
am Di., 8. Sep. 2020, 22:32:
> On Tue, 8 Sep 2020 20:27:20 +0200
> Jonas Maebe via fpc-pascal <fpc-pascal at lists.freepascal.org> 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.
>
Why does c4 fail however? Shouldn't the compiler insert a type conversion
from codepage 1250 to CP_ACP which is UTF-8 in Lazarus?
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200908/2731440b/attachment.htm>
More information about the fpc-pascal
mailing list