Closed glanium closed 5 days ago
In my machine, when
java -jar .dart_tool/jnigen/ApiSummarizer.jar -c "jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar" --backend asm okhttp3.OkHttpClient > test.txt
test.txt is in UTF16-LE
when
java -jar .dart_tool/jnigen/ApiSummarizer.jar -c "jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar" --backend asm okhttp3.OkHttpClient -o test.txt
using -o option,
test.txt is in UTF8
I see, it worked on my machine using ja-JP, that's why I closed it.
I can replace System.out
with new PrintStream(System.out, true, StandardCharsets.UTF_8);
and try again. I'll tag you in the PR to check it on your machine using git dependency so we're sure this time the issue is actually fixed.
I've upgraded to jni 0.9.0 and jnigen 0.9.0. However, I've got same FormatException error as https://github.com/dart-lang/native/issues/877
I've investigated the issue and there is one more cause.
https://github.com/dart-lang/native/blob/95d226d290d4d5c583c4e45b04048442f244c656/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java#L63C1-L71C6
When options.outputFile is specified, FileOutputStream is used for output. This is ok. However, when options.outputFile is not specified, System.out is used. This is problem. System.out is type of PrintStream! PrintStream is encoding-aware! So i guess jackson's JsonSerializer outputs json as UTF-16 in ja-JP locale by invoking PrintStream's encoding-aware methods.
thx.