Skip to content

Commit d285234

Browse files
committedOct 12, 2023
Fix wrong output encoding on Windows with JDK >= 19 (fixes #247) (#258)
* 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
1 parent cdb8d8c commit d285234

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed
 

‎src/main/java/org/fusesource/jansi/AnsiConsole.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ private static AnsiPrintStream ansiStream(boolean stdout) {
237237
FileDescriptor descriptor = stdout ? FileDescriptor.out : FileDescriptor.err;
238238
final OutputStream out = new FastBufferedOutputStream(new FileOutputStream(descriptor));
239239

240-
String enc = System.getProperty(stdout ? "sun.stdout.encoding" : "sun.stderr.encoding");
240+
String enc = System.getProperty(stdout ? "stdout.encoding" : "stderr.encoding");
241+
if (enc == null) {
242+
enc = System.getProperty(stdout ? "sun.stdout.encoding" : "sun.stderr.encoding");
243+
}
241244

242245
final boolean isatty;
243246
boolean isAtty;

‎src/main/java/org/fusesource/jansi/AnsiMain.java

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public static void main(String... args) throws IOException {
8585
+ "os.version= " + System.getProperty("os.version") + ", "
8686
+ "os.arch= " + System.getProperty("os.arch"));
8787
System.out.println("file.encoding= " + System.getProperty("file.encoding"));
88+
System.out.println("sun.stdout.encoding= " + System.getProperty("sun.stdout.encoding") + ", "
89+
+ "sun.stderr.encoding= " + System.getProperty("sun.stderr.encoding"));
90+
System.out.println("stdout.encoding= " + System.getProperty("stdout.encoding") + ", " + "stderr.encoding= "
91+
+ System.getProperty("stderr.encoding"));
8892
System.out.println("java.version= " + System.getProperty("java.version") + ", "
8993
+ "java.vendor= " + System.getProperty("java.vendor") + ","
9094
+ " java.home= " + System.getProperty("java.home"));

‎src/main/resources/org/fusesource/jansi/jansi.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[?7h
2-
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
1+
[?7h
2+
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
33
│██├┘█████└┬┘█████└┬┘██████│▐▌│
44
┌──┐ │██│██▄▄▄██│██┌─┐██│██▄▄▄▄ │▄▄│
55
│▒▒└─┘▒█│▒█┌─┐▒█│▒█│ │▒█│ ▀▀▀▀▒█│▒█│

0 commit comments

Comments
 (0)
Please sign in to comment.