From 34c0d9cd916b65ce19beaf3f1b782c87758873e7 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Mon, 30 May 2016 19:53:17 +0200
Subject: [PATCH] Made java decoding of strings to explicitly use UTF8

---
 lib/java/se/lth/control/labcomm2014/DecoderChannel.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/java/se/lth/control/labcomm2014/DecoderChannel.java b/lib/java/se/lth/control/labcomm2014/DecoderChannel.java
index 1a819a2..7f65331 100644
--- a/lib/java/se/lth/control/labcomm2014/DecoderChannel.java
+++ b/lib/java/se/lth/control/labcomm2014/DecoderChannel.java
@@ -5,9 +5,12 @@ import java.io.DataInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.EOFException;
+import java.nio.charset.Charset;
 
 public class DecoderChannel implements Decoder {
 
+  private final Charset UTF8_CHARSET = Charset.forName("UTF-8");
+
   private DataInputStream in;
   private DecoderRegistry def_registry = new DecoderRegistry();
   private DecoderRegistry ref_registry = new DecoderRegistry();
@@ -131,7 +134,7 @@ public class DecoderChannel implements Decoder {
     for(int i=0; i<len; i++) {
       chars[i] = in.readByte();
     }
-    return new String(chars);
+    return new String(chars, UTF8_CHARSET);
   }
 
   public int decodePacked32() throws IOException {
-- 
GitLab