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

@ -48,7 +48,8 @@ public class JsonRpcDispatcherCommand implements LocalCommand {
m.setIgnoreAttachments(ignoreAttachments);
final var jsonOutputWriter = (JsonWriter) outputWriter;
final Supplier<String> lineSupplier = IOUtils.getLineSupplier(new InputStreamReader(System.in));
final Supplier<String> lineSupplier = IOUtils.getLineSupplier(new InputStreamReader(System.in,
IOUtils.getConsoleCharset()));
final var handler = new SignalJsonRpcDispatcherHandler(jsonOutputWriter, lineSupplier, false);
handler.handleConnection(m);

View file

@ -24,7 +24,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -120,7 +119,7 @@ public class SendCommand implements JsonRpcLocalCommand {
if (readMessageFromStdin || (messageText == null && sticker == null)) {
logger.debug("Reading message from stdin...");
try {
messageText = IOUtils.readAll(System.in, Charset.defaultCharset());
messageText = IOUtils.readAll(System.in, IOUtils.getConsoleCharset());
} catch (IOException e) {
throw new UserErrorException("Failed to read message from stdin: " + e.getMessage());
}