protobuf-java-format icon indicating copy to clipboard operation
protobuf-java-format copied to clipboard

Issue #35 - printToString doesn't encode to bytes

Open tonicsoft opened this issue 7 years ago • 9 comments

For any AbstractCharBasedFormatter, printToString can print directly to a String and not have to convert to bytes and back again. This avoids call to ByteArrayOutputStream.toString() at ProtobufFormatter:91 which uses JVM default encoding instead of ProtobufFormatter.defaultCharset. (I discovered this issue when trying to create JSON with a broad range of unicode characters on a machine where the default Charset did not cover the full Unicode range.)

tonicsoft avatar Sep 19 '16 23:09 tonicsoft

Please update https://github.com/bivas/protobuf-java-format/blob/master/RELEASE-NOTES.md for this fix in 1.5.

scr avatar Feb 23 '17 16:02 scr

Would you mind fixing the issue you pointed out in Issue #35 ?

https://github.com/bivas/protobuf-java-format/blob/master/src/main/java/com/googlecode/protobuf/format/ProtobufFormatter.java#L91

Basically,

Convert this to

return new String(out.getBytes(), defaultCharset);

scr avatar Feb 23 '17 16:02 scr

Sure - shall I create a new issue/PR etc or just tag onto this one?

tonicsoft avatar Feb 23 '17 16:02 tonicsoft

Done - just added change to this issue, found another bug too.

tonicsoft avatar Feb 24 '17 23:02 tonicsoft

So sorry, but recent RELEASE-NOTES change for #37 collide with yours… please resolve the conflicts and upload.

scr avatar Feb 28 '17 18:02 scr

Conflicts resolved. Should be ready for merging now.

tonicsoft avatar Feb 28 '17 23:02 tonicsoft

Is this PR still in progress now? Without this PR, We have to invoke print() method and convert a OutputStream to String manually

onesuper avatar Feb 01 '18 03:02 onesuper

any update on this?

luigi-riefolo avatar Jun 28 '19 15:06 luigi-riefolo

I am no longer working on this, apologies.

Please feel free to take it up.

tonicsoft avatar Jun 28 '19 17:06 tonicsoft