Repository: workcraft/workcraft
Issue: Incorrect display of UTF-8 symbols in Output window

With the move from Java 8 to Java 11 an interesting problem appeared -- the default charset in Windows, as identified by JVM, changed from *UTF-8* to *windows-1252*. As a result, some of UTF-8 characters (e.g. →) became corrupted in the *Output* window. 

One solution to this issue is to explicitly specify UTF-8 encoding on String-bytes conversion, and when dealing with streams. For this `StandardCharsets.UTF_8` should be passed as the last parameter, at least to the following functions (there may be more):
* `String.getBytes()`
* `new String(bytes)`
* `new String(bytes, offset, length)`
* `new PrintStream(file)`
* `new InputStreamReader(stream)`

Another (complementary) solution is to pass `-Dfile.encoding=UTF-8` to the JVM thus enforcing the default encoding.

Changed files:
workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessTask.java
workcraft/WorkcraftCore/src/org/workcraft/utils/WorkUtils.java
workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoSolver.java
workcraft/WorkcraftCore/src/org/workcraft/gui/tasks/TaskFailureNotifier.java
workcraft/WorkcraftCore/src/org/workcraft/gui/OutputWindow.java
workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExecutionSupport.java
workcraft/WorkcraftCore/src/org/workcraft/gui/ErrorWindow.java
workcraft/WorkcraftCore/src/org/workcraft/utils/FileUtils.java
workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessOutput.java
workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/VisualModelSerialisationTests.java
workcraft/PlatoPlugin/src/org/workcraft/plugins/plato/tasks/PlatoResultHandler.java
workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/StgSerialisationTests.java
workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/MathModelSerialisationTests.java
workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/AlgebraExpressionFromGraphsCommand.java
workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/ExtractSelectedGraphsPGMinerCommand.java
workcraft/CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java

diff --git a/workcraft/CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java b/workcraft/CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java
index 5a9a9aded..37a73a88b 100644
--- a/workcraft/CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java
+++ b/workcraft/CircuitPlugin/src/org/workcraft/plugins/circuit/interop/VerilogImporter.java
@@ -44,6 +44,7 @@ import javax.swing.*;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 public class VerilogImporter implements Importer {
@@ -592,7 +593,7 @@ public class VerilogImporter implements Importer {
     }
 
     private Expression convertFormulaToExpression(String formula) {
-        InputStream expressionStream = new ByteArrayInputStream(formula.getBytes());
+        InputStream expressionStream = new ByteArrayInputStream(formula.getBytes(StandardCharsets.UTF_8));
         ExpressionParser expressionParser = new ExpressionParser(expressionStream);
         if (DebugCommonSettings.getParserTracing()) {
             expressionParser.enable_tracing();
diff --git a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/AlgebraExpressionFromGraphsCommand.java b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/AlgebraExpressionFromGraphsCommand.java
index fc485e286..eaa194fc5 100644
--- a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/AlgebraExpressionFromGraphsCommand.java
+++ b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/AlgebraExpressionFromGraphsCommand.java
@@ -12,8 +12,9 @@ import org.workcraft.utils.WorkspaceUtils;
 import org.workcraft.workspace.WorkspaceEntry;
 
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 
 public class AlgebraExpressionFromGraphsCommand extends AbstractAlgebraCommand {
 
@@ -57,10 +58,10 @@ public class AlgebraExpressionFromGraphsCommand extends AbstractAlgebraCommand {
                 }
                 PrintStream expressions;
                 try {
-                    expressions = new PrintStream(file);
+                    expressions = new PrintStream(file, StandardCharsets.UTF_8);
                     expressions.print(exp);
                     expressions.close();
-                } catch (FileNotFoundException e) {
+                } catch (IOException e) {
                     e.printStackTrace();
                 }
             } else {
diff --git a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/ExtractSelectedGraphsPGMinerCommand.java b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/ExtractSelectedGraphsPGMinerCommand.java
index b7febbb4b..d804fddc8 100644
--- a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/ExtractSelectedGraphsPGMinerCommand.java
+++ b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/commands/ExtractSelectedGraphsPGMinerCommand.java
@@ -13,6 +13,7 @@ import org.workcraft.workspace.WorkspaceEntry;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 
 public class ExtractSelectedGraphsPGMinerCommand extends AbstractPGMinerCommand {
@@ -56,7 +57,7 @@ public class ExtractSelectedGraphsPGMinerCommand extends AbstractPGMinerCommand
             }
 
             File inputFile = File.createTempFile("input", ".tr");
-            PrintStream expressions = new PrintStream(inputFile);
+            PrintStream expressions = new PrintStream(inputFile, StandardCharsets.UTF_8);
             for (String graph: graphs) {
                 expressions.println(graph);
             }
diff --git a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExecutionSupport.java b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExecutionSupport.java
index 959f86d6d..6de149333 100644
--- a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExecutionSupport.java
+++ b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExecutionSupport.java
@@ -23,6 +23,7 @@ import org.workcraft.utils.Geometry;
 
 import java.awt.geom.Point2D;
 import java.io.*;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
@@ -88,9 +89,8 @@ public class ScencoExecutionSupport {
         if (f.exists() && !f.isDirectory()) {
             System.out.println("Boolean controller:");
             try {
-                FileInputStream fstream = new FileInputStream(fileName);
-                DataInputStream in = new DataInputStream(fstream);
-                BufferedReader bre = new BufferedReader(new InputStreamReader(in));
+                DataInputStream in = new DataInputStream(new FileInputStream(fileName));
+                BufferedReader bre = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
                 String strLine;
                 bre.readLine();
                 bre.readLine();
@@ -256,7 +256,7 @@ public class ScencoExecutionSupport {
             File scenarioFile, File encodingFile, EncoderSettings settings) {
         try {
 
-            PrintStream output = new PrintStream(scenarioFile);
+            PrintStream output = new PrintStream(scenarioFile, StandardCharsets.UTF_8);
 
             for (int k = 0; k < m; k++) {
                 Map<String, Integer> nodes = new HashMap<>();
@@ -354,7 +354,7 @@ public class ScencoExecutionSupport {
             if (settings.getGenMode() != GenerationMode.SCENCO) {
 
                 if (settings.isCustomEncMode()) {
-                    PrintStream output1 = new PrintStream(encodingFile);
+                    PrintStream output1 = new PrintStream(encodingFile, StandardCharsets.UTF_8);
 
                     String[] enc = settings.getCustomEnc();
                     for (int k = 0; k < m; k++) {
diff --git a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoSolver.java b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoSolver.java
index 8ec8d9d6b..67cc07269 100644
--- a/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoSolver.java
+++ b/workcraft/CpogPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoSolver.java
@@ -18,8 +18,9 @@ import org.workcraft.workspace.WorkspaceEntry;
 
 import java.awt.geom.Point2D;
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.StringTokenizer;
@@ -209,8 +210,8 @@ public class ScencoSolver {
             boolean[][] encoding = solution.getCode();
             PrintStream output = null;
             try {
-                output = new PrintStream(encodingFile);
-            } catch (FileNotFoundException e) {
+                output = new PrintStream(encodingFile, StandardCharsets.UTF_8);
+            } catch (IOException e) {
                 e.printStackTrace();
             }
 
diff --git a/workcraft/PlatoPlugin/src/org/workcraft/plugins/plato/tasks/PlatoResultHandler.java b/workcraft/PlatoPlugin/src/org/workcraft/plugins/plato/tasks/PlatoResultHandler.java
index 58d749e89..42a6c4463 100644
--- a/workcraft/PlatoPlugin/src/org/workcraft/plugins/plato/tasks/PlatoResultHandler.java
+++ b/workcraft/PlatoPlugin/src/org/workcraft/plugins/plato/tasks/PlatoResultHandler.java
@@ -38,6 +38,7 @@ import javax.swing.*;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
 
@@ -155,7 +156,7 @@ public class PlatoResultHandler extends BasicProgressMonitor<ExternalProcessOutp
     private void addStg(String output, Framework framework, GraphEditor editor, String[] invariants)
             throws IOException, DeserialisationException, OperationCancelledException {
 
-        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(output.getBytes())) {
+        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(output.getBytes(StandardCharsets.UTF_8))) {
             ModelEntry me = new StgImporter().importFrom(inputStream, null);
             MathModel mathModel = me.getMathModel();
             StgDescriptor stgModel = new StgDescriptor();
@@ -177,7 +178,7 @@ public class PlatoResultHandler extends BasicProgressMonitor<ExternalProcessOutp
     private void addFst(String output, Framework framework, GraphEditor editor)
             throws IOException, DeserialisationException, OperationCancelledException {
 
-        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(output.getBytes())) {
+        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(output.getBytes(StandardCharsets.UTF_8))) {
             ModelEntry me = new SgImporter().importFrom(inputStream, null);
             MathModel mathModel = me.getMathModel();
             FstDescriptor fstModel = new FstDescriptor();
diff --git a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/MathModelSerialisationTests.java b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/MathModelSerialisationTests.java
index d95c44117..7352be3cd 100644
--- a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/MathModelSerialisationTests.java
+++ b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/MathModelSerialisationTests.java
@@ -11,6 +11,8 @@ import org.workcraft.plugins.builtin.serialisation.XMLModelSerialiser;
 import org.workcraft.plugins.stg.Stg;
 import org.workcraft.shared.DataAccumulator;
 
+import java.nio.charset.StandardCharsets;
+
 class MathModelSerialisationTests {
 
     @Test
@@ -33,7 +35,7 @@ class MathModelSerialisationTests {
             DataAccumulator accumulator = new DataAccumulator();
             serialiser.serialise(stg, accumulator, null);
 
-            System.out.println(new String(accumulator.getData()));
+            System.out.println(new String(accumulator.getData(), StandardCharsets.UTF_8));
 
             // deserialise
             XMLModelDeserialiser deserisaliser = new XMLModelDeserialiser(mock);
diff --git a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/StgSerialisationTests.java b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/StgSerialisationTests.java
index 13e8e230d..b6d5ade91 100644
--- a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/StgSerialisationTests.java
+++ b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/StgSerialisationTests.java
@@ -15,6 +15,8 @@ import org.workcraft.shared.DataAccumulator;
 import org.workcraft.workspace.ModelEntry;
 import org.workcraft.workspace.WorkspaceEntry;
 
+import java.nio.charset.StandardCharsets;
+
 class StgSerialisationTests {
 
     @Test
@@ -38,9 +40,9 @@ class StgSerialisationTests {
         DataAccumulator visualData = new DataAccumulator();
         serialiser.serialise(stg, visualData, mathModelReferences);
 
-        System.out.println(new String(mathData.getData()));
+        System.out.println(new String(mathData.getData(), StandardCharsets.UTF_8));
         System.out.println("---------------");
-        System.out.println(new String(visualData.getData()));
+        System.out.println(new String(visualData.getData(), StandardCharsets.UTF_8));
 
         // deserialise
         XMLModelDeserialiser deserialiser = new XMLModelDeserialiser(mockPluginManager);
diff --git a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/VisualModelSerialisationTests.java b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/VisualModelSerialisationTests.java
index 2948b0186..8a3f69b65 100644
--- a/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/VisualModelSerialisationTests.java
+++ b/workcraft/StgPlugin/test-src/org/workcraft/plugins/stg/serialisation/VisualModelSerialisationTests.java
@@ -16,6 +16,8 @@ import org.workcraft.shared.DataAccumulator;
 import org.workcraft.workspace.ModelEntry;
 import org.workcraft.workspace.WorkspaceEntry;
 
+import java.nio.charset.StandardCharsets;
+
 class VisualModelSerialisationTests {
 
     @Test
@@ -42,9 +44,9 @@ class VisualModelSerialisationTests {
         DataAccumulator visualData = new DataAccumulator();
         serialiser.serialise(visualstg, visualData, mathModelReferences);
 
-        System.out.println(new String(mathData.getData()));
+        System.out.println(new String(mathData.getData(), StandardCharsets.UTF_8));
         System.out.println("---------------");
-        System.out.println(new String(visualData.getData()));
+        System.out.println(new String(visualData.getData(), StandardCharsets.UTF_8));
 
         // deserialise
         XMLModelDeserialiser deserialiser = new XMLModelDeserialiser(mockPluginManager);
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/gui/ErrorWindow.java b/workcraft/WorkcraftCore/src/org/workcraft/gui/ErrorWindow.java
index 3ee2e0745..074c2d377 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/gui/ErrorWindow.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/gui/ErrorWindow.java
@@ -10,6 +10,7 @@ import java.awt.*;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.io.*;
+import java.nio.charset.StandardCharsets;
 
 @SuppressWarnings("serial")
 public class ErrorWindow extends LogPanel implements ComponentListener {
@@ -27,7 +28,7 @@ public class ErrorWindow extends LogPanel implements ComponentListener {
             if (systemErr != null) {
                 systemErr.write(b);
             }
-            displayInEventDispatchThread(new String(b));
+            displayInEventDispatchThread(new String(b, StandardCharsets.UTF_8));
         }
 
         @Override
@@ -35,7 +36,7 @@ public class ErrorWindow extends LogPanel implements ComponentListener {
             if (systemErr != null) {
                 systemErr.write(b, off, len);
             }
-            displayInEventDispatchThread(new String(b, off, len));
+            displayInEventDispatchThread(new String(b, off, len, StandardCharsets.UTF_8));
         }
 
         private void displayInEventDispatchThread(String s) {
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/gui/OutputWindow.java b/workcraft/WorkcraftCore/src/org/workcraft/gui/OutputWindow.java
index 45ab8d009..8504df41b 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/gui/OutputWindow.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/gui/OutputWindow.java
@@ -9,6 +9,7 @@ import org.workcraft.utils.LogUtils;
 import javax.swing.*;
 import java.awt.*;
 import java.io.*;
+import java.nio.charset.StandardCharsets;
 
 @SuppressWarnings("serial")
 public class OutputWindow extends LogPanel {
@@ -28,7 +29,7 @@ public class OutputWindow extends LogPanel {
             if (systemOut != null) {
                 systemOut.write(b);
             }
-            displayInEventDispatchThread(new String(b));
+            displayInEventDispatchThread(new String(b, StandardCharsets.UTF_8));
         }
 
         @Override
@@ -36,7 +37,7 @@ public class OutputWindow extends LogPanel {
             if (systemOut != null) {
                 systemOut.write(b, off, len);
             }
-            displayInEventDispatchThread(new String(b, off, len));
+            displayInEventDispatchThread(new String(b, off, len, StandardCharsets.UTF_8));
         }
 
         private void displayInEventDispatchThread(String text) {
@@ -101,7 +102,7 @@ public class OutputWindow extends LogPanel {
     public void captureStream() {
         if (!streamCaptured) {
             OutputStreamView outView = new OutputStreamView(new ByteArrayOutputStream(), getTextArea());
-            PrintStream outStream = new PrintStream(outView);
+            PrintStream outStream = new PrintStream(outView, true, StandardCharsets.UTF_8);
             systemOut = System.out;
             System.setOut(outStream);
             streamCaptured = true;
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/gui/tasks/TaskFailureNotifier.java b/workcraft/WorkcraftCore/src/org/workcraft/gui/tasks/TaskFailureNotifier.java
index d877d0ea5..0e5ddb668 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/gui/tasks/TaskFailureNotifier.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/gui/tasks/TaskFailureNotifier.java
@@ -5,6 +5,7 @@ import org.workcraft.tasks.Result;
 import org.workcraft.utils.DialogUtils;
 
 import javax.swing.*;
+import java.nio.charset.StandardCharsets;
 
 public class TaskFailureNotifier extends BasicProgressMonitor<Object> {
     private final String description;
@@ -16,7 +17,7 @@ public class TaskFailureNotifier extends BasicProgressMonitor<Object> {
 
     @Override
     public void stderr(byte[] data) {
-        errorMessage += new String(data);
+        errorMessage += new String(data, StandardCharsets.UTF_8);
     }
 
     @Override
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessOutput.java b/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessOutput.java
index 8f5447855..f6ac9fd9f 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessOutput.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessOutput.java
@@ -2,6 +2,8 @@ package org.workcraft.tasks;
 
 import org.workcraft.utils.TextUtils;
 
+import java.nio.charset.StandardCharsets;
+
 public class ExternalProcessOutput {
 
     private final int returnCode;
@@ -27,7 +29,7 @@ public class ExternalProcessOutput {
     }
 
     public String getStdoutString() {
-        return new String(stdout);
+        return new String(stdout, StandardCharsets.UTF_8);
     }
 
     public byte[] getStderr() {
@@ -35,7 +37,7 @@ public class ExternalProcessOutput {
     }
 
     public String getStderrString() {
-        return new String(stderr);
+        return new String(stderr, StandardCharsets.UTF_8);
     }
 
     public String getErrorsHeadAndTail() {
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessTask.java b/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessTask.java
index 2fd9e3899..86e1e24bb 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessTask.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/tasks/ExternalProcessTask.java
@@ -7,6 +7,7 @@ import org.workcraft.utils.LogUtils;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 public class ExternalProcessTask implements Task<ExternalProcessOutput>, ExternalProcessListener {
@@ -87,7 +88,7 @@ public class ExternalProcessTask implements Task<ExternalProcessOutput>, Externa
         }
         monitor.stdout(data);
         if (printStdout) {
-            String text = new String(data);
+            String text = new String(data, StandardCharsets.UTF_8);
             LogUtils.logStdout(text);
         }
     }
@@ -101,7 +102,7 @@ public class ExternalProcessTask implements Task<ExternalProcessOutput>, Externa
         }
         monitor.stderr(data);
         if (printStderr) {
-            String text = new String(data);
+            String text = new String(data, StandardCharsets.UTF_8);
             LogUtils.logStderr(text);
         }
     }
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/utils/FileUtils.java b/workcraft/WorkcraftCore/src/org/workcraft/utils/FileUtils.java
index a9a8b2552..80ce1da4f 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/utils/FileUtils.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/utils/FileUtils.java
@@ -45,7 +45,7 @@ public class FileUtils {
 
     public static void dumpString(File out, String string) throws IOException {
         try (FileOutputStream fos = new FileOutputStream(out)) {
-            fos.write(string.getBytes());
+            fos.write(string.getBytes(StandardCharsets.UTF_8));
         }
     }
 
diff --git a/workcraft/WorkcraftCore/src/org/workcraft/utils/WorkUtils.java b/workcraft/WorkcraftCore/src/org/workcraft/utils/WorkUtils.java
index f56b93f61..bc29d0adc 100644
--- a/workcraft/WorkcraftCore/src/org/workcraft/utils/WorkUtils.java
+++ b/workcraft/WorkcraftCore/src/org/workcraft/utils/WorkUtils.java
@@ -521,7 +521,7 @@ public final class WorkUtils {
                 String adjustedAttribute = attribute.replace(path, fileReference.getPath());
                 line = line.replace(attribute, adjustedAttribute);
             }
-            os.write(line.getBytes());
+            os.write(line.getBytes(StandardCharsets.UTF_8));
         }
         return new Resource(resource.getName(), os);
     }