Skip to content
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

Box drawing characters don't print correctly after AnsiConsole.systemInstall() in cmd.exe #247

Closed
codemonstur opened this issue Jan 27, 2023 · 4 comments
Milestone

Comments

@codemonstur
Copy link

I want to print some box drawing characters to the screen. Here is my code:

public static void main(final String... args) {
    AnsiConsole.systemInstall();
    System.out.println("\u2514\u2500");
}

However this prints:

C:\Projects\public\test>java -jar target/test.jar
ÔööÔöÇ

If I remove the AnsiConsole.systemInstall() I get this:

C:\Projects\public\test>java -jar target/test.jar
└─

On linux everything is fine. This only breaks on windows (tested with cmd.exe and Windows Home 11).
I do want to continue using AnsiConsole because I want to print colors. And that part works great. I don't want to have to choose between colors or fancy drawing.

@gnodet
Copy link
Member

gnodet commented Aug 22, 2023

@codemonstur could you please provide the output of java -jar jansi-2.4.0.jar ?

@codemonstur
Copy link
Author

codemonstur commented Aug 23, 2023

Hey @gnodet, I already did. See my comment here: #227 (comment)

@gnodet
Copy link
Member

gnodet commented Sep 25, 2023

@codemonstur I've reproduced the issue when running on JDK 21. Could you double check that it works for you with JDK 11 ? I'll investigate and try to find a fix in the mean time...

@codemonstur
Copy link
Author

codemonstur commented Sep 26, 2023

The problem exists on JDK11 as well. The logo did come out right, but those truecolor and 256 color is probably not what it should be.

C:\Users\jurgen\Downloads>java --version
openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

C:\Users\jurgen\Downloads>java -jar jansi-2.4.0.jar
Jansi 2.4.0

library.jansi.path=
library.jansi.version=
Jansi native library loaded from C:\Users\jurgen\AppData\Local\Temp\jansi-2.4.0-ef82fc841702d1c5-jansi.dll
   which was auto-extracted from jar:file:/C:/Users/jurgen/Downloads/jansi-2.4.0.jar!/org/fusesource/jansi/internal/native/Windows/x86_64/jansi.dll

os.name= Windows 10, os.version= 10.0, os.arch= amd64
file.encoding= Cp1252
java.version= 11.0.1, java.vendor= Oracle Corporation, java.home= C:\Programs\jdk-11

jansi.graceful=
jansi.mode=
jansi.out.mode=
jansi.err.mode=
jansi.colors=
jansi.out.colors=
jansi.err.colors=
jansi.passthrough= false
jansi.strip= false
jansi.force= false
jansi.noreset= false
org.fusesource.jansi.Ansi.disable= false

IS_WINDOWS: true
IS_CONEMU: false
IS_CYGWIN: false
IS_MSYSTEM: false

isatty(STDOUT_FILENO): 1, System.out is a terminal
isatty(STDERR_FILENO): 1, System.err is a terminal

Resulting Jansi modes for stout/stderr streams:
  - System.out: AnsiPrintStream{type=VirtualTerminal, colors=Colors16, mode=Default, resetAtUninstall=true}
  - System.err: AnsiPrintStream{type=VirtualTerminal, colors=Colors16, mode=Default, resetAtUninstall=true}
Processor types description:
  - Native: Supports ansi sequences natively
  - Unsupported: Ansi sequences are stripped out
  - VirtualTerminal: Supported through windows virtual terminal
  - Emulation: Emulated through using windows API console commands
  - Redirected: The stream is redirected to a file or a pipe
Colors support description:
  - Colors16: 16 colors
  - Colors256: 256 colors
  - TrueColor: 24-bit colors
Modes description:
  - Strip: Strip all ansi sequences
  - Default: Print ansi sequences if the stream is a terminal
  - Force: Always print ansi sequences, even if the stream is redirected

image

There is a bit too much data to stuff it all into one screenshot. So I copy-pasted the regular text at the top and made a screenshot only of the colored bits.

@gnodet gnodet added this to the 2.5.0 milestone Sep 27, 2023
@gnodet gnodet closed this as completed in fcc630b Sep 28, 2023
gnodet added a commit that referenced this issue Oct 12, 2023
* Fix wrong output encoding on Windows with JDK >= 19

JDK 19 has changed the system properties used for System.out and System.err encoding, see https://www.oracle.com/java/technologies/javase/19-relnote-issues.html#JDK-8283620

* Fix bad background in logo and add output encoding system properties
@gnodet gnodet modified the milestones: 2.5.0, 2.4.1 Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants