SCM

[#1011144] The output byte buffer is too small to contain the encoded data

View Trackers | Bugs | Download .csv | Monitor

Date:
2012-01-09 16:27
Priority:
3
State:
Open
Submitted by:
Chupa Kabra (chupakabra)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.11
Category:
Group:
Resolution:
None
Summary:
The output byte buffer is too small to contain the encoded data

Detailed description
Sometimes I got exception using NpgsqlCopySerializer: The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes

To fix it you can replace following code (line 437)
------------------------------
if (escapeAt > bufferedUpto)
{
int encodedLength = ENCODING_UTF8.GetByteCount(fieldValue.ToCharArray(bufferedUpto, escapeAt));
MakeRoomForBytes(encodedLength);
_sendBufferAt += ENCODING_UTF8.GetBytes(fieldValue, bufferedUpto, escapeAt, _sendBuffer, _sendBufferAt);
bufferedUpto = escapeAt;
}
------------------------------
to
------------------------------
if (escapeAt > bufferedUpto)
{
char[] array = fieldValue.ToCharArray(bufferedUpto, escapeAt - bufferedUpto);
int encodedLength = ENCODING_UTF8.GetByteCount(array);
MakeRoomForBytes(encodedLength + _sendBufferAt);
_sendBufferAt += ENCODING_UTF8.GetBytes(fieldValue, bufferedUpto, escapeAt - bufferedUpto, _sendBuffer, _sendBufferAt);
bufferedUpto = escapeAt;
}
------------------------------

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge