Discussions related to Visual Prolog
VPExplorer
Posts: 22
Joined: 6 Aug 2012 16:56

How to initialize the console for ansi or ascii?

Unread post by VPExplorer »

Hi,

What packages need to be included to do a

Code: Select all

     console::init(stream::ansi)   %(Is this syntax correct?)
?

I'm getting an undeclared identifier for stream::ansi, but I'm not sure where stream is located.

So far, I've got

open core, console, console_native, console_api
User avatar
Thomas Linder Puls
VIP Member
Posts: 1295
Joined: 28 Feb 2000 0:01

Re: How to initialize the console for ansi or ascii?

Unread post by Thomas Linder Puls »

Notice the However below.

You already have the necessary package included, the problem is that ansi needs a codepage argument:

Code: Select all

interface stream     open core   domains     mode =         unicode;         ansi(codePage CP);         binary.  
So an initialization could look like this:

Code: Select all

    console::init(stream::ansi(codePageId::codePage_windows1251))
However a default console program has already initialized the console to utf8 in the goal:

Code: Select all

goal     console::runUtf8(main::run).
I think the best choice is utf8 (old ASCII is a subset of utf8), but if you must use another codepage you should write (with the codepage of your choice obviously):

Code: Select all

goal     console::run8(main::run, codePageId::codePage_windows1251).
Regards Thomas Linder Puls
PDC
VPExplorer
Posts: 22
Joined: 6 Aug 2012 16:56

Re: How to initialize the console for ansi or ascii?

Unread post by VPExplorer »

Thank you, sir.

For most purposes UTF8 is the standard correct choice. But the samples I'm playing with won't require it. For this, I'll use ansi or ascii.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1295
Joined: 28 Feb 2000 0:01

Re: How to initialize the console for ansi or ascii?

Unread post by Thomas Linder Puls »

I will still think it is a bad choice to not to choose utf8 (plain ANSI/ASCII characters are a subset of utf8).
Regards Thomas Linder Puls
PDC
VPExplorer
Posts: 22
Joined: 6 Aug 2012 16:56

Re: How to initialize the console for ansi or ascii?

Unread post by VPExplorer »

I know, thanks Thomas.
Thomas Linder Puls wrote: 31 Jan 2022 9:53 I will still think it is a bad choice to not to choose utf8 (plain ANSI/ASCII characters are a subset of utf8).
Post Reply