I am using a NIO
CharsetDecoder to covert from bytes to chars in a UTF-8 environment. I received the following
OK, that’s helpful. After a little code splunking I determined that this means that the error is “malformed” (pretty obvious) and the length is “1” (not so obvious).
What’s interesting about the
CoderResult is that not only does it not fit any other paradigm used in the SDK but telling me the length of the erroneous input is, for all intents and purposes, useless. What would have been more helpful is to have included the position in the input buffer at which the malformed result occurred. Luckily
CharsetDecoder.decode() advances the buffers as it reads so that you can use its current position as a guide (I should point out that this is mentioned in
Now I just need to determine why bytes that are supposedly UTF-8 have a value of
Since my problem is clearly not on my end, I have added:
to circumvent the problem. This will use the
CharsetDecoder‘s replacement value to replace any malformed characters.