MicroInstructionMemoryParser and MainMemoryParser now use UTF-8
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 30 Oct 2019 21:21:58 +0000 (22:21 +0100)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 30 Oct 2019 21:21:58 +0000 (22:21 +0100)
plugins/net.mograsim.machine/src/net/mograsim/machine/mi/MicroInstructionMemoryParser.java
plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java

index a141a86..3cf971a 100644 (file)
@@ -6,6 +6,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 
 import net.mograsim.machine.mi.parameters.MicroInstructionParameter;
 import net.mograsim.machine.mi.parameters.ParameterClassification;
@@ -49,7 +50,7 @@ public class MicroInstructionMemoryParser
         */
        public static void parseMemory(final MicroInstructionMemory memory, InputStream input) throws IOException
        {
-               try (BufferedReader reader = new BufferedReader(new InputStreamReader(input)))
+               try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)))
                {
                        MicroInstructionMemoryDefinition def = memory.getDefinition();
                        MicroInstructionDefinition miDef = def.getMicroInstructionDefinition();
@@ -129,7 +130,8 @@ public class MicroInstructionMemoryParser
                                int val = instStream.read();
                                if (val == -1 && instIndex <= maxAddress)
                                {
-                                       instStream = new ByteArrayInputStream((toCSV(memory.getCell(instIndex++)) + lineSeparator).getBytes());
+                                       instStream = new ByteArrayInputStream(
+                                                       (toCSV(memory.getCell(instIndex++)) + lineSeparator).getBytes(StandardCharsets.UTF_8));
                                        val = instStream.read();
                                }
                                return val;
index d52efdc..c3b0d68 100644 (file)
@@ -6,6 +6,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 
 import net.mograsim.logic.core.types.BitVector;
 import net.mograsim.machine.MainMemory;
@@ -50,7 +51,7 @@ public class MainMemoryParser
         */
        public static void parseMemory(final MainMemory memory, InputStream input) throws IOException
        {
-               try (BufferedReader reader = new BufferedReader(new InputStreamReader(input)))
+               try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)))
                {
                        MainMemoryDefinition def = memory.getDefinition();
 
@@ -86,7 +87,8 @@ public class MainMemoryParser
                                int val = instStream.read();
                                if (val == -1 && instIndex <= maxAddress)
                                {
-                                       instStream = new ByteArrayInputStream((memory.getCell(instIndex++).toBitstring() + lineSeparator).getBytes());
+                                       instStream = new ByteArrayInputStream(
+                                                       (memory.getCell(instIndex++).toBitstring() + lineSeparator).getBytes(StandardCharsets.UTF_8));
                                        val = instStream.read();
                                }
                                return val;