Changeset 13619 in josm for trunk


Ignore:
Timestamp:
2018-04-12T09:27:35+02:00 (19 months ago)
Author:
stoecker
Message:

better encoding support, see #14655

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r13593 r13619  
    102102        cli.q(longOpt:'josmxml', args:1, argName:"josmxml", "JOSM entries reoutput as XML file (incomplete)")
    103103        cli.m(longOpt:'noeli', argName:"noeli", "don't show output for ELI problems")
     104        cli.c(longOpt:'encoding', args:1, argName:"encoding", "output encoding (defaults to UTF-8 or cp850 on Windows)")
    104105        cli.h(longOpt:'help', "show this help")
    105106        options = cli.parse(args)
     
    119120        }
    120121        if (options.output && options.output != "-") {
     122            String ccp = options.encoding
     123            if (ccp == null)
     124                ccp = "UTF-8"
    121125            outputFile = new FileOutputStream(options.output)
    122             outputStream = new OutputStreamWriter(outputFile, "UTF-8")
     126            outputStream = new OutputStreamWriter(outputFile, ccp)
     127        } else {
     128            String ccp = options.encoding
     129            if (ccp == null) {
     130                String osn  = System.getProperty("os.name")
     131                ccp = (osn != null && osn.contains("Windows")) ? "cp850" : "UTF-8"
     132            }
     133            outputStream = new OutputStreamWriter(System.out, ccp)
    123134        }
    124135    }
     
    206217
    207218    void loadELIEntries() {
    208         FileReader fr = new FileReader(eliInputFile)
     219        def fr = new InputStreamReader(new FileInputStream(eliInputFile), "UTF-8")
    209220        JsonReader jr = Json.createReader(fr)
    210221        eliEntries = jr.readObject().get("features")
Note: See TracChangeset for help on using the changeset viewer.