Skip to content

Commit f1e9459

Browse files
committed
test(exec): 补 UTF-8 解码回归测试(POSIX printf 八进制转义,跨 BSD/GNU shell)
1 parent 1fbfc11 commit f1e9459

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/test/java/io/github/easy4j/codex/cli/CodexCliExecutorTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ void shouldPassArgumentsRawWithoutEmbeddedQuotes() {
101101
"multi-word arguments must arrive without embedded literal quotes");
102102
}
103103

104+
@Test
105+
void shouldDecodeChildOutputAsUtf8() {
106+
// The CLIs emit UTF-8 regardless of platform; decoding with the
107+
// platform default charset would mojibake on GBK-default Windows.
108+
// You = \344\275\240, Hao = \345\245\275 (POSIX printf octal escapes).
109+
CodexCliExecutor executor = new CodexCliExecutor(configFor("/bin/sh"));
110+
111+
CodexCliResult result = executor.executeWithStdin(null, "-c", "printf '\\344\\275\\240\\345\\245\\275'");
112+
113+
assertEquals("你好", result.getStdout(),
114+
"child output must be decoded as UTF-8, not the platform default charset");
115+
}
116+
104117
@Test
105118
void shouldIgnoreNullArguments() {
106119
CodexCliExecutor executor = new CodexCliExecutor(configFor("/bin/echo"));

0 commit comments

Comments
 (0)