You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<paramname="chars">The span that contains the set of characters to encode.</param>
167
+
<summary>Calculates the number of bytes produced by encoding the specified character span.</summary>
168
+
<returns>The number of bytes produced by encoding the specified character span.</returns>
169
+
<remarks>
170
+
<formattype="text/markdown"><![CDATA[
171
+
172
+
## Remarks
173
+
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, use <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
<paramname="chars">The character span to encode.</param>
447
+
<paramname="bytes">The span to contain the resulting set of bytes.</param>
448
+
<summary>Encodes the specified character span into the specified byte span.</summary>
449
+
<returns>The actual number of bytes written into <paramrefname="bytes" />.</returns>
450
+
<remarks>
451
+
<formattype="text/markdown"><![CDATA[
452
+
453
+
## Remarks
454
+
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, use <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
455
+
456
+
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
457
+
458
+
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any Unicode character greater than `U+007F` is encoded as the ASCII question mark ("?").
459
+
460
+
> [!CAUTION]
461
+
> For security reasons, you should use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
<paramname="bytes">The span containing the set of bytes to decode.</param>
793
+
<summary>Calculates the number of characters produced by decoding the specified byte span.</summary>
794
+
<returns>The number of characters produced by decoding the specified byte span.</returns>
795
+
<remarks>
796
+
<formattype="text/markdown"><![CDATA[
797
+
798
+
## Remarks
799
+
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetChars%2A> to store the resulting characters, use <xref:System.Text.ASCIIEncoding.GetCharCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A>. The <xref:System.Text.ASCIIEncoding.GetCharCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A> method generally executes faster.
<paramname="bytes">The span containing the bytes to decode.</param>
1001
+
<paramname="chars">The span to contain the resulting set of characters.</param>
1002
+
<summary>Decodes the specified byte span into the specified character span.</summary>
1003
+
<returns>The actual number of characters written into <paramrefname="chars" />.</returns>
1004
+
<remarks>
1005
+
<formattype="text/markdown"><![CDATA[
1006
+
1007
+
## Remarks
1008
+
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetChars%2A> to store the resulting characters, use <xref:System.Text.ASCIIEncoding.GetCharCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A>. The <xref:System.Text.ASCIIEncoding.GetCharCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A> method generally executes faster.
1009
+
1010
+
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, you should use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
1011
+
1012
+
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any byte greater than hexadecimal `0x7F` is decoded as the Unicode question mark ("?").
1013
+
1014
+
> [!CAUTION]
1015
+
> For security reasons, you should use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
<summary>Gets a Unicode byte order mark encoded in UTF-32 format, if this object is configured to supply one.</summary>
1766
+
<value>A byte span containing the Unicode byte order mark, if this object is configured to supply one; otherwise, a default span.</value><remarks>
1767
+
<formattype="text/markdown"><.
1791
+
1792
+
> [!IMPORTANT]
1793
+
> To ensure that the encoded bytes are decoded properly, you should prefix encoded bytes with a preamble. Note that the <xref:System.Text.UTF32Encoding.GetBytes%2A> method does not prepend a BOM to a sequence of encoded bytes; supplying a BOM at the beginning of an appropriate byte stream is the developer's responsibility.
0 commit comments