Skip to content

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

Closed

Description

@codemonstur

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.

Activity

  1. gnodet commented on Aug 22, 2023

    @gnodet
    Member

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

  2. codemonstur commented on Aug 23, 2023

    @codemonstur
    Author

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

  3. gnodet commented on Sep 25, 2023

    @gnodet
    Member

    @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...

  4. codemonstur commented on Sep 26, 2023

    @codemonstur
    Author

    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.

  5. added this to the 2.5.0 milestone on Sep 27, 2023
  6. added a commit that references this issue on Oct 12, 2023
    d285234
  7. modified the milestones: 2.5.0, 2.4.1 on Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions