Use console charset for reading/writing to stdin/out

This commit is contained in:
AsamK 2022-05-26 14:49:16 +02:00
parent 425e451237
commit e03c48e0ae
4 changed files with 9 additions and 5 deletions

View file

@ -46,7 +46,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
@ -123,7 +122,7 @@ public class App {
var outputType = outputTypeInput == null
? command.getSupportedOutputTypes().stream().findFirst().orElse(null)
: outputTypeInput;
var writer = new BufferedWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
var writer = new BufferedWriter(new OutputStreamWriter(System.out, IOUtils.getConsoleCharset()));
var outputWriter = outputType == null
? null
: outputType == OutputType.JSON ? new JsonWriterImpl(writer) : new PlainTextWriterImpl(writer);