From bf05802b9bd02e2d4ac72960c4ce46b2c2369c1e Mon Sep 17 00:00:00 2001 From: Phan Huy Nguyen Date: Fri, 7 Dec 2018 18:30:51 +0800 Subject: [PATCH] Fix ProtobufFormatter.printToString to use the defaultCharset when convert byte[] to String --- .../com/googlecode/protobuf/format/ProtobufFormatter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/googlecode/protobuf/format/ProtobufFormatter.java b/src/main/java/com/googlecode/protobuf/format/ProtobufFormatter.java index 95288f3..d70594f 100644 --- a/src/main/java/com/googlecode/protobuf/format/ProtobufFormatter.java +++ b/src/main/java/com/googlecode/protobuf/format/ProtobufFormatter.java @@ -88,7 +88,7 @@ public String printToString(final Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); print(message, out, defaultCharset); out.flush(); - return out.toString(); + return out.toString(defaultCharset.name()); } catch (IOException e) { throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).", e); @@ -103,7 +103,7 @@ public String printToString(final UnknownFieldSet fields) { ByteArrayOutputStream out = new ByteArrayOutputStream(); print(fields, out, defaultCharset); out.flush(); - return out.toString(); + return out.toString(defaultCharset.name()); } catch (IOException e) { throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).", e);