Skip to content

Commit afc8b82

Browse files
authored
Document Decoder.Convert exception conditions
The doc incorrectly stated in the remarks section that this method does not throw when the output buffer is too small. In its exception section it incorrectly indicates that the output buffer must be large enough for the entire input buffer. The correction indicates that the output buffer need only be **2 chars** in length in order to avoid the exception.
1 parent 66489f0 commit afc8b82

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

xml/System.Text/Decoder.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Any remaining processed data that is part of a logical unit, such as the high su
172172
173173
The `Convert` method is designed to be used in a loop to decode an arbitrary amount of input, such as data read from a file or stream.
174174
It stores the output of the decoding operation in a fixed-size buffer.
175-
<xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written.
175+
<xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written, provided the output array allows for at least two characters.
176176
Also see <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> for more comments.
177177
178178
]]></format>
@@ -315,7 +315,7 @@ The `completed` parameter can also be set to `false`, even though the `bytesUsed
315315
<paramref name="chars" /> or <paramref name="bytes" /> is <see langword="null" /> (<see langword="Nothing" />).</exception>
316316
<exception cref="T:System.ArgumentOutOfRangeException">
317317
<paramref name="charCount" /> or <paramref name="byteCount" /> is less than zero.</exception>
318-
<exception cref="T:System.ArgumentException">The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the <see cref="Overload:System.Text.Decoder.GetCharCount" /> method.</exception>
318+
<exception cref="T:System.ArgumentException">The output buffer is too small to contain any of the converted input. The output buffer should be at least 2 chars in size to accomodate at least one surrogate character pair.</exception>
319319
<exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (for more information, see <see href="~/docs/standard/base-types/character-encoding.md">Character Encoding in .NET</see>)
320320

321321
-and-
@@ -417,7 +417,7 @@ The following example uses the <xref:System.Text.Encoder.Convert%2A> method to c
417417
-or-
418418

419419
The length of <paramref name="bytes" /> - <paramref name="byteIndex" /> is less than <paramref name="byteCount" />.</exception>
420-
<exception cref="T:System.ArgumentException">The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the <see cref="Overload:System.Text.Decoder.GetCharCount" /> method.</exception>
420+
<exception cref="T:System.ArgumentException">The output buffer is too small to contain any of the converted input. The output buffer should be at least 2 chars in size to accomodate at least one surrogate character pair.</exception>
421421
<exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (for more information, see <see href="~/docs/standard/base-types/character-encoding.md">Character Encoding in .NET</see>)
422422

423423
-and-
@@ -898,7 +898,7 @@ The following example uses the <xref:System.Text.Encoder.Convert%2A> method to c
898898
899899
If `GetChars` is called with `flush` set to `false`, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call `GetCharCount` on a block of data immediately before calling `GetChars` on the same block, so that any trailing bytes from the previous block are included in the calculation.
900900
901-
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output span isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
901+
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output span isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written, provided the output array allows for at least two characters. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
902902
903903
]]></format>
904904
</remarks>
@@ -972,7 +972,7 @@ The following example uses the <xref:System.Text.Encoder.Convert%2A> method to c
972972
973973
If `GetChars` is called with `flush` set to `false`, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call `GetCharCount` on a block of data immediately before calling `GetChars` on the same block, so that any trailing bytes from the previous block are included in the calculation.
974974
975-
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
975+
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written, provided the output array allows for at least two characters. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
976976
977977
]]></format>
978978
</remarks>
@@ -1055,7 +1055,7 @@ The following example uses the <xref:System.Text.Encoder.Convert%2A> method to c
10551055
10561056
If `GetChars` is called with `flush` set to `false`, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call `GetCharCount` on a block of data immediately before calling `GetChars` on the same block, so that any trailing bytes from the previous block are included in the calculation.
10571057
1058-
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
1058+
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written, provided the output array allows for at least two characters. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
10591059
10601060
10611061
@@ -1157,7 +1157,7 @@ The following example uses the <xref:System.Text.Encoder.Convert%2A> method to c
11571157
11581158
If `GetChars` is called with `flush` set to `false`, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call `GetCharCount` on a block of data immediately before calling `GetChars` on the same block, so that any trailing bytes from the previous block are included in the calculation.
11591159
1160-
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
1160+
If your application is to convert many segments of an input stream, consider using the <xref:System.Text.Decoder.Convert%2A> method. <xref:System.Text.Decoder.GetChars%2A> will throw an exception if the output buffer isn't large enough, but <xref:System.Text.Decoder.Convert%2A> will fill as much space as possible and return the bytes read and chars written, provided the output array allows for at least two characters. Also see the <xref:System.Text.Encoding.GetChars%2A?displayProperty=nameWithType> topic for more comments.
11611161
11621162
]]></format>
11631163
</remarks>

0 commit comments

Comments
 (0)