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

Bart bartjunk64 at gmail.com
Wed Sep 9 10:02:16 CEST 2020


On Wed, Sep 9, 2020 at 8:37 AM LacaK via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

> I am still confused how this CodePage aware stuff is expected to work and when implicit conversios are included (as far as I understand here ONLY declared/static codepage plays role) and when dynamic codepage is taken into account and when not?

You are not the only one.
Given that I am on Lazarus, so all my source files are UTF8 encoded I
got confused by this:
unit1
{$codepage utf8}
interface
const
  msCopy = 'Kopiƫren...';
....

Than in main program:
Label1.Caption := msgCopy;

This does not show the text correctly.
I have to include {$codepage utf8} in the source code file that
contains the "Label1.Caption := msgCopy;" otherwise it does not
display correctly.
So basically I have that in all source code that does display text (in a GUI).
And if I do so, I can omit the codepage directive in unit1.
This is a bit counter intuitive to me.

-- 
Bart


More information about the fpc-pascal mailing list