enforce UTF-8 encoding in data streams
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 18 Nov 2013 06:45:30 +0000 (08:45 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 18 Nov 2013 06:45:30 +0000 (08:45 +0200)
src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java
src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java

index e093619..b0db879 100644 (file)
@@ -41,7 +41,7 @@ public class EnhancedDataInputStream extends DataInputStream {
                final byte[] bytes = new byte[length];
                readFully(bytes);
 
-               return new String(bytes);
+               return new String(bytes, "UTF-8");
        }
 
 }
index 24e8029..2476bbc 100644 (file)
@@ -33,7 +33,7 @@ public class EnhancedDataOutputStream extends DataOutputStream {
                        return;
                }
 
-               final byte[] bytes = string.getBytes();
+               final byte[] bytes = string.getBytes("UTF-8");
 
                writeInt(bytes.length);
                write(bytes);