-
Notifications
You must be signed in to change notification settings - Fork 398
Description
I am encountering an issue with a Spring Shell v4 non-interactive application. When running the application in a Windows terminal, output that contains UTF-8 characters outside the BMP displays those characters as question marks.
I believe that this is because the NonInteractiveShellRunner uses System.console for output which uses the terminal's default character set (IBM437). The JLine library supports writing unicode characters out to the console, so using it resolves this issue.
This is a Spring Shell v3 to v4 Migration issue. Under Spring Shell v3, non-interactive applications still used JLine for console output but under Spring Shell v4, System.console is used.
It would be nice if the JLine library made a non-interactive ShellRunner class available to replace the default NonInteractiveShellRunner in order to make the JLine capabilities available when the JLine starter is used.
The following code demonstrates the issue in Spring Shell v4:
package io.github.rmcdouga;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.core.command.annotation.Command;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Command(name = "example")
public String example() {
return "Hello World! \u2665"; // Should display a heart symbol but displays question mark instead.
}
}The equivilent code works under Spring Shell v3:
package io.github.rmcdouga;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.CommandScan;
@SpringBootApplication
@CommandScan
@Command
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Command(command = "example")
public String example() {
return "Hello World! \u2665"; // Displays a heart symbol
}
}