[fpc-pascal]How to display special characters

Rich Pasco pasco at acm.org
Tue Mar 19 19:55:54 CET 2002


Juha Nevalainen wrote:

> If I wanted to
> maintain original text readability (there is lots of text with lots of
> specials chars in this program), the only way then is to switch back to text
> mode editor then, right?

If you want to read your strings in the source code, then you need
to edit them in the same codepage as you execute them in.  But for
code portability, do something like this:

const
{$ifdef DOS_CHARS}
  eacute = #$82;
  a-umlaut = #$84;
{$else} (* Windows characters *)
  eacute = #$E9;
  a-umlaut = #$E4;
{$endif}
...
begin
  ...
  WriteLn("ol"+eacute);
  WriteLn("sp"+aumlaut+"t");
  ...

> How about printing - is that all in ISO-8859-1 too?   Will I need
> the Windows character sequences for that part then?

It depends on how you print.  If you print from a Windows app (e.g.
Notepad), then yes, the characters must be in ISO-8859-1.  But if you
pipe your program output directly to PRN (the printer device) then use
your printer's native character set (consult the printer manual).

     - Rich




More information about the fpc-pascal mailing list