From: Svjatoslav Agejenko Date: Mon, 18 Nov 2013 06:45:30 +0000 (+0200) Subject: enforce UTF-8 encoding in data streams X-Git-Tag: svjatoslavcommons-1.8~123 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=950e3080cac96cd9167745cb18830e53418d1795;p=svjatoslav_commons.git enforce UTF-8 encoding in data streams --- diff --git a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java index e093619..b0db879 100644 --- a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java +++ b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java @@ -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"); } } diff --git a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java index 24e8029..2476bbc 100644 --- a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java +++ b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java @@ -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);