Skip to content

Commit

Permalink
Fix wrong output encoding on Windows with JDK >= 19 (fixes #247) (#258)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gnodet committed Oct 12, 2023
1 parent cdb8d8c commit d285234
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/fusesource/jansi/AnsiConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ private static AnsiPrintStream ansiStream(boolean stdout) {
FileDescriptor descriptor = stdout ? FileDescriptor.out : FileDescriptor.err;
final OutputStream out = new FastBufferedOutputStream(new FileOutputStream(descriptor));

String enc = System.getProperty(stdout ? "sun.stdout.encoding" : "sun.stderr.encoding");
String enc = System.getProperty(stdout ? "stdout.encoding" : "stderr.encoding");
if (enc == null) {
enc = System.getProperty(stdout ? "sun.stdout.encoding" : "sun.stderr.encoding");
}

final boolean isatty;
boolean isAtty;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/fusesource/jansi/AnsiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public static void main(String... args) throws IOException {
+ "os.version= " + System.getProperty("os.version") + ", "
+ "os.arch= " + System.getProperty("os.arch"));
System.out.println("file.encoding= " + System.getProperty("file.encoding"));
System.out.println("sun.stdout.encoding= " + System.getProperty("sun.stdout.encoding") + ", "
+ "sun.stderr.encoding= " + System.getProperty("sun.stderr.encoding"));
System.out.println("stdout.encoding= " + System.getProperty("stdout.encoding") + ", " + "stderr.encoding= "
+ System.getProperty("stderr.encoding"));
System.out.println("java.version= " + System.getProperty("java.version") + ", "
+ "java.vendor= " + System.getProperty("java.vendor") + ","
+ " java.home= " + System.getProperty("java.home"));
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/org/fusesource/jansi/jansi.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[?7h
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
[?7h
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
│██├┘█████└┬┘█████└┬┘██████│▐▌│
┌──┐ │██│██▄▄▄██│██┌─┐██│██▄▄▄▄ │▄▄│
│▒▒└─┘▒█│▒█┌─┐▒█│▒█│ │▒█│ ▀▀▀▀▒█│▒█│
Expand Down

0 comments on commit d285234

Please sign in to comment.