[fpc-pascal] String literals and code page of .pas source file

LacaK lacak at zoznam.sk
Mon Sep 7 08:51:02 CEST 2020


Hello Jonas,

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
   label3.Caption:=c3;       // OK
   label4.Caption:=c4;       // FAIL
end;

TIA

-Laco.


>> I would like to have source file in Windows-1250 encoding, where are
>> stored literal strings like 'áéíóčž' in Windows-1250 encoding (I share
>> this one file between FPC/Lazarus and Delphi 7). Windows-1250 is also
>> ANSI code page of my Windows OS. In source file I have:
>>
>> {$IFDEF FPC}
>>    {$CODEPAGE cp1250}
>> {$ENDIF}
>>
>> and in Lazarus I have set: File settings / Encoding / CP1250
>> (at this point in .pas file are all characters correctly encoded in
>> Windows-1250 code page)
>>
>> When I compile application and run it, string literals (characters with
>> accents) are not preserved.
>> Is there way how to get it working?
> The attached program uses the same environment as Lazarus
> (DefaultSystemCodePage forced to UTF-8) and prints the string correctly
> for me (under Mac OS X).
>
> Please always provide a compilable program when reporting issues.
>
>
> Jonas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_cp1250.ZIP
Type: application/x-zip-compressed
Size: 2630 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200907/7fa7293a/attachment.bin>


More information about the fpc-pascal mailing list