From 950e3080cac96cd9167745cb18830e53418d1795 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Mon, 18 Nov 2013 08:45:30 +0200 Subject: [PATCH] enforce UTF-8 encoding in data streams --- .../eu/svjatoslav/commons/data/EnhancedDataInputStream.java | 2 +- .../eu/svjatoslav/commons/data/EnhancedDataOutputStream.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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); -- 2.20.1