]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Use default charset for tech type CSV parsing 17/4417/3
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 31 Aug 2020 13:07:03 +0000 (16:07 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 1 Sep 2020 06:40:47 +0000 (06:40 +0000)
gitlab #93

Change-Id: Iba22b4ea4db7a772664e2b76ab44a88a70ea8e80

org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java

index 0b6edb5f51785773811c53b33153aff354af2e8c..d9dac92c5586c5924fbf6fe7e1fc2796aa85d3ef 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.district.imports;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -65,7 +66,7 @@ public class DistrictImportUtils {
     public static Map<String, Integer> readCSVHeader(Path source, CSVFormat format, boolean firstAsHeader) throws IOException {
         if (firstAsHeader)
             format = format.withFirstRecordAsHeader();
-        try (CSVParser parser = format.parse(Files.newBufferedReader(source))) {
+        try (CSVParser parser = format.parse(Files.newBufferedReader(source, Charset.defaultCharset()))) {
             return parser.getHeaderMap();
         }
     }
index eb83c902ddf535c9bcd8ae236de40913d33bf4a6..3b3d4a7014f13cbdc924ef46368f3111db828dfa 100644 (file)
@@ -196,7 +196,7 @@ public class TechTypeTable extends Composite {
        public void setTechTypePath(String path) {
                String data;
                try {
-                       data = Files.lines(Paths.get(path)).collect(Collectors.joining("\n"));
+                       data = Files.lines(Paths.get(path), Charset.defaultCharset()).collect(Collectors.joining("\n"));
                } catch (IOException e) {
                        LOGGER.error("Failed to read contents of file '{}' as {}", path, Charset.defaultCharset(), e);
                        return;