No permission to encoding a (user_) stream?

I think this should be a good option. Thanks.

I just tried “swipl-w64-2022-05-04.exe Tue May 3 20:23:43 2022 12,968,860” in windows 7 (in VMware). It seems that it doesn’t fix anything:

Given a UTF-8 file encoding.pl

If I set nothing in init.pl, then

In windows 7 command line with 65001:

c:\work-pl\prolog>swipl encoding.pl
ERROR: c:/work-pl/prolog/encoding.pl:3:21: Syntax error: illegal_character
ERROR: c:/work-pl/prolog/encoding.pl:5:1: Syntax error: End of file in quoted string
Warning: c:/work-pl/prolog/encoding.pl:19:
Warning:    'c:/work-pl/prolog/encoding.pl':19:8: Illegal multibyte Sequence
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.10-53-g5637fed39)

In windows 7 Emacs with UTF-8 encoding:

?- consult(["encoding.pl"]).
ERROR: c:/work-pl/prolog/encoding.pl:3:21: Syntax error: illegal_character
ERROR: c:/work-pl/prolog/encoding.pl:5:1: Syntax error: End of file in quoted string
Warning: c:/work-pl/prolog/encoding.pl:19:
Warning:    'c:/work-pl/prolog/encoding.pl':19:8: Illegal multibyte Sequence

If I set

:- set_prolog_flag(encoding, utf8).

in init.pl, then

In windows 7 command line with 65001:

It is OK.

In windows 7 Emacs with UTF-8 encoding:

?- consult(["encoding.pl "]).
ERROR: c:/work-pl/prolog/encoding.pl :3:21: Syntax error: illegal_character
ERROR: c:/work-pl/prolog/encoding.pl :5:1: Syntax error: End of file in quoted string
Warning: c:/work-pl/prolog/encoding.pl :20:
Warning:    'c:/work-pl/prolog/encoding.pl ':20:0: Illegal multibyte Sequence

Therefore, in order to fix the Emacs’ problem, I still need to set init.pl

:- set_prolog_flag(encoding, utf8).
:- set_stream(user_input,  encoding(utf8)).
:- set_stream(user_output, encoding(utf8)).
:- set_stream(user_error,  encoding(utf8)).

But that will cause the “No permission” problem when running in command line.

All in all, there is nothing to be changed.