Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-06

Different default ASCII tablein fpc IDE with SP3 installed

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Noel and Marie

Hello,

Recently SP3 for XP was installed on my PC.

An fpc 2.2.0 program that previously displayed a square root symbol when instructed to write chr(251) now displays a superscript 1. In other words, the character set displayed in the IDE through Tools ->ascii table is different from the one previously displayed.

Can you give instructions on how to have the program use the former character set please?

Thanks,
Noel

Reply by email

Tomas Hajny
to Noel and Marie

On Mon, June 21, 2010 10:19, Noel and Marie wrote:

Hello,

Show quoted text 9 lines
Recently SP3 for XP was installed on my PC. An fpc 2.2.0 program that previously displayed a square root symbol when instructed to write chr(251) now displays a superscript 1. In other words, the character set displayed in the IDE through Tools ->ascii table is different from the one previously displayed. Can you give instructions on how to have the program use the former character set please?

There are several options for you:

1) Change the console code page to the preferred character set before starting the program (e.g. by calling 'cp 437' on the command line or from a batch file before invoking your program). Advantage: No change to the program is required. Disadvantage: Change necessary on each and every machine where the program runs.

2) Change the console code page to the preferred character set using the Win32 API from within the program. Advantage: No user changes necessary. Disadvantage: Platform dependent change (if you aim to support multiple platforms), no chance for the user to use a different character set (i.e. no possibility of displaying characters used in other languages any longer).

3) Start using widestrings / Unicode characters. Advantage: Your programs becomes completely independent from the used character set and allows reliable displaying of whichever characters you may need (as long as they are supported by the installed fonts, of course). Disadvantage: Depending on the way your program is currently written / output to console is performed, major changes to your program may be necessary.

Hope this helps

Tomas

Reply by email

Noel and Marie
to Tomas Hajny

Thank you Tomas for your suggestions and very quick response.

Regards,
Noel

Earlier message 50 lines
----- Original Message ----- From: "Tomas Hajny" To: "FPC-Pascal users discussions" Sent: Monday, June 21, 2010 6:27 PM Subject: Re: [fpc-pascal] Different default ASCII tablein fpc IDE with SP3 installed On Mon, June 21, 2010 10:19, Noel and Marie wrote: Hello, > Recently SP3 for XP was installed on my PC. > > An fpc 2.2.0 program that previously displayed a square root symbol when > instructed to write chr(251) now displays a superscript 1. In other words, > the character set displayed in the IDE through Tools ->ascii table is > different from the one previously displayed. > > Can you give instructions on how to have the program use the former > character set please? There are several options for you: 1) Change the console code page to the preferred character set before starting the program (e.g. by calling 'cp 437' on the command line or from a batch file before invoking your program). Advantage: No change to the program is required. Disadvantage: Change necessary on each and every machine where the program runs. 2) Change the console code page to the preferred character set using the Win32 API from within the program. Advantage: No user changes necessary. Disadvantage: Platform dependent change (if you aim to support multiple platforms), no chance for the user to use a different character set (i.e. no possibility of displaying characters used in other languages any longer). 3) Start using widestrings / Unicode characters. Advantage: Your programs becomes completely independent from the used character set and allows reliable displaying of whichever characters you may need (as long as they are supported by the installed fonts, of course). Disadvantage: Depending on the way your program is currently written / output to console is performed, major changes to your program may be necessary. Hope this helps Tomas

Reply by email

Noel and Marie
to Tomas Hajny: There are several options for you: 1) Change the console code page to the preferred…

Tomas,

I tried two of your suggestions.

1.
In a command shell I went to the working directory c:\fpc\2.2.0\demo\text then entered chcp.
The response was: Active code page: 850
I then entered chcp 437
The response was: Active code page: 437
I then ran the program squareroot_n.exe which has a line: write('Square root ', chr(251));
However, it still printed superscript 1 rather than the square root symbol.

2.
I modified the source code to now use the Windows  unit as well as the crt
unit.
I added the following lines:
  writeln( getConsoleCP);
  writeln(  getConsoleOutputCP);
  setConsoleOutputCP(437);
  writeln( getConsoleOutputCP);

The output was :
850
437
437

and unfortunately, still the superscript 1 instead of the desired square root symbol in response to the instruction to write( 'Square root ', chr(251));

Thank you again for your suggestions but I wonder if you could suggest anything else before I embark on trying to learn about widestrings and unicodes.

Noel

Earlier message 50 lines
----- Original Message ----- From: "Tomas Hajny" To: "FPC-Pascal users discussions" Sent: Monday, June 21, 2010 6:27 PM Subject: Re: [fpc-pascal] Different default ASCII tablein fpc IDE with SP3 installed On Mon, June 21, 2010 10:19, Noel and Marie wrote: Hello, > Recently SP3 for XP was installed on my PC. > > An fpc 2.2.0 program that previously displayed a square root symbol when > instructed to write chr(251) now displays a superscript 1. In other words, > the character set displayed in the IDE through Tools ->ascii table is > different from the one previously displayed. > > Can you give instructions on how to have the program use the former > character set please? There are several options for you: 1) Change the console code page to the preferred character set before starting the program (e.g. by calling 'cp 437' on the command line or from a batch file before invoking your program). Advantage: No change to the program is required. Disadvantage: Change necessary on each and every machine where the program runs. 2) Change the console code page to the preferred character set using the Win32 API from within the program. Advantage: No user changes necessary. Disadvantage: Platform dependent change (if you aim to support multiple platforms), no chance for the user to use a different character set (i.e. no possibility of displaying characters used in other languages any longer). 3) Start using widestrings / Unicode characters. Advantage: Your programs becomes completely independent from the used character set and allows reliable displaying of whichever characters you may need (as long as they are supported by the installed fonts, of course). Disadvantage: Depending on the way your program is currently written / output to console is performed, major changes to your program may be necessary. Hope this helps Tomas

Reply by email