How do I accept non-english characters when using ComponentFlow in Spring Shell?
It works fine with non-english characters when using the Shell normally, but when using the ComponentFlow it does not. When you press a key, it seems to ignore the input.
@ShellComponent
public class TestCommand {
@ShellMethod(key = "test-locale")
public String testLocale() {
logger.info("Terminal is not null. Charset: " + terminal.encoding().displayName());
ComponentFlow flow = componentFlowBuilder.clone()
.withStringInput("testString").and().build();
ComponentFlowResult result = flow.run();
return "testString = " + result.getContext().get("testString");
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>name</name>
<properties>
<java.version>21</java.version>
<spring-shell.version>3.3.1</spring-shell.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-dependencies</artifactId>
<version>${spring-shell.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The output of the above is UTF-8, but it's still not accepting non-english characters.
This is currently not supported in flow components. There's partial support in other parts so I created 1115 to handle it in StringInput
as well.