fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.1k stars 139 forks source link

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

Closed codemonstur closed 9 months ago

codemonstur commented 1 year ago

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 commented 11 months ago

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

codemonstur commented 10 months ago

Hey @gnodet, I already did. See my comment here: https://github.com/fusesource/jansi/issues/227#issuecomment-1406240133

gnodet commented 9 months ago

@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 commented 9 months ago

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.