I have a problem when trying to convert bytes to String in Java, with code like:
byte[] bytes = {1, 2, -3};
byte[] transferred = new String(bytes, Charsets.
The encoded values you are getting, [-17, -65, -67] correspond to Unicode code point 0xFFFD
. If you look up that code point, the Unicode specification tells you that 0XFFFD
"used to replace an incoming character whose value is unknown or unrepresentable in Unicode." And as others have pointed out, -3
without any followup code-units is broken UTF-8, so this character is appropriate.