-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output encoding issues on Windows #2976
Comments
Note that for Python, the better environment variable to use would be If we later decide to change all of our target languages to produce UTF-8 always, then we would move to |
Unfortunately, that Python documentation is correct for Python 3.7, but wrong for Python 3.8+, as documented in python/cpython#86427 , so the situation is even more complicated for Python than it is for Java. Here is the issue:
|
This is intended to make it possible to test Unicode output. I skipped Java because Java needs a separate patch (since it doesn't respect the current encoding / codepage, see #2976)
Fixed in 2976. |
Implementation of the design from dafny-lang/rfcs#13. Resolves #413. Fixes #2928. Fixes #818. Fixes #3058. Fixes #1293. Fixes #3001. Depends on #2976 to be fixed for the tests to pass consistently across platforms. I've documented some of the less obvious compilation strategy decisions in `docs/Compilation/StringsAndChars.md`. <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
On Windows, the following program prints (with
dafny run
) different outputs depending on the compiler that it gets executed on:Specifically:
On Windows in
cmd.exe
:Arguably, this is the user's fault: the above happens because the default
cmd.exe
codepage doesn't even have the € character. So, let's fix that:On windows with
chcp 65001
(the utf-8 codepage):C# and JS are good. Python and Java are not.
Python can be fixed with
PYTHONIOENCODING=utf8
.The only way to fix java is to use
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
, but unfortunately that also pollutes the output:On Ubuntu/WSL:
Much better (in particular, java respects LANG, and that defaults to
<something>.UTF-8
)macOS
(from @robin-aws)
Note the
%
symbols show up as highlighted in my console. I haven't yet inspected the raw bytes of the output to figure those out. If I change the program toprint [8364 as char], "\n";
they go away.The problem
When using
dafny build
users can configure the environment and invoke the runtime however they want (e.g. pass-Dfile.encoding=UTF-8
tojava
on the command line, which doesn't produce "picked up …" warnings).For
dafny run
, things are not so simple. For some of our languages there are ways to configure things (chcp
for C# andnode
,PYTHONIOENCODING
for Python), but for Java there is onlyJAVA_TOOL_OPTIONS
, which pollutes the output of every Java program.Should we change
dafny run
to pass-Dfile.encoding=UTF-8
tojava
directly?PS: Here's a useful small program to test things out in Java; use
javac Encoding.java
andjava Encoding
to run it:The text was updated successfully, but these errors were encountered: