Ticket #18608: 18608v1.patch

File 18608v1.patch, 2.0 KB (added by gaben, 2 months ago)

my first patch ever on the internet :)

  • src/org/openstreetmap/josm/tools/Logging.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    66import java.io.OutputStream;
    77import java.io.PrintWriter;
    88import java.io.StringWriter;
     9import java.io.UnsupportedEncodingException;
     10import java.nio.charset.StandardCharsets;
    911import java.text.MessageFormat;
    1012import java.util.ArrayList;
    1113import java.util.Arrays;
     
    131133        LOGGER.setLevel(Level.ALL);
    132134        LOGGER.setUseParentHandlers(false);
    133135
     136        //Default output encoding string on all systems
     137        String outputEncoding = StandardCharsets.UTF_8.toString();
     138
    134139        // for a more concise logging output via java.util.logging.SimpleFormatter
    135140        Utils.updateSystemProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT.%1$tL %4$s: %5$s%6$s%n");
    136141
    137142        ConsoleHandler stderr = new ReacquiringConsoleHandler(() -> System.err, null);
    138143        LOGGER.addHandler(stderr);
     144
     145        try {
     146            stderr.setEncoding(outputEncoding);
     147        } catch (UnsupportedEncodingException e) {
     148            System.err.println("Unable to set output encoding: " + e.getMessage());
     149        }
     150
    139151        try {
    140152            stderr.setLevel(LEVEL_WARN);
    141153        } catch (SecurityException e) {
     
    144156
    145157        ConsoleHandler stdout = new ReacquiringConsoleHandler(() -> System.out, stderr);
    146158        LOGGER.addHandler(stdout);
     159
     160        try {
     161            stdout.setEncoding(outputEncoding);
     162        } catch (UnsupportedEncodingException e) {
     163            System.err.println("Unable to set output encoding: " + e.getMessage());
     164        }
     165
    147166        try {
    148167            stdout.setLevel(Level.ALL);
    149168        } catch (SecurityException e) {