ubjson / universal-binary-json-java

Universal Binary JSON Java Library
http://ubjson.org
Apache License 2.0
33 stars 4 forks source link

writeString in UBJOutputStream:200 fails on special characters #2

Open Jegp opened 11 years ago

Jegp commented 11 years ago

Hope you don't mind me posting an issue here. Thanks for publishing your work!

I found a bug when writing strings in the UBJOutputStream. In line 205 the length of the string is potentially wrong, since the size of a byte-array encoded from a String is greater than the size of the string - when the string contains special characters. So "abc" will have the correct size of 3, while "æøå" (danish characters) will require extra bytes to store.

I don't know if there is a fix for it without encoding the string.

ghost commented 10 years ago

@Jegp Argh, damn good catch. I will need to fix this.