Encoding.UTF8.GetString: The output char buffer is too small... #31698
Labels
area-System.Text.Encoding
question
Answer questions and provide assistance, not an issue with source code or documentation.
untriaged
New issue has not been triaged by the area owner
NET 3.1
Feeding some garbage data into Encoding.UTF8.GetString, I occasionally get this exception:
System.ArgumentException: 'The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. (Parameter 'chars')'
Stack trace:
I was accidentally using it on binary data while doing some debugging.
It happened using the ReadOnlySpan overload, but these byte arrays are the data:
Neither of these is reproducible though.
Even when visual studio has the "Exception Thrown!" exception window open and highlighted, re-executing the same statement doesn't throw an exception the second time.
My suspicion would be something to do with ArrayPool, if that's even used by this method.
Not sure how to be more useful with this one...
The text was updated successfully, but these errors were encountered: