1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
<Type Name="Encoder" FullName="System.Text.Encoder" FullNameSP="System_Text_Encoder" Maintainer="ecma">
<TypeSignature Language="ILASM" Value=".class public abstract serializable Encoder extends System.Object" />
<TypeSignature Language="C#" Value="public abstract class Encoder" />
<MemberOfLibrary>BCL</MemberOfLibrary>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
</AssemblyInfo>
<ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
<Docs>
<summary>
<para> Converts blocks of characters into blocks of bytes. </para>
</summary>
<remarks>
<para>
<block subset="none" type="note">Following instantiation of a <see cref="T:System.Text.Encoder" />, sequential
blocks of characters are converted into blocks of bytes through calls to the
<see cref="M:System.Text.Encoder.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32,System.Boolean)" /> method. The encoder maintains state between the
conversions, allowing it to correctly encode character sequences that span
adjacent blocks. An instance of a specific implementation of the
<see cref="T:System.Text.Encoder" />
class is typically obtained
through a call to the <see cref="M:System.Text.Encoding.GetEncoder" /> .</block>
</para>
</remarks>
<example>
<para>The following example demonstrates using the <see cref="T:System.Text.UTF8Encoding" />
implementation of the <see cref="T:System.Text.Encoder" /> class to convert one character array to two byte
arrays.</para>
<code lang="C#">using System;
using System.Text;
public class EncoderExample
{
public static void Main()
{
string str = "Encoder";
char[] cAry = str.ToCharArray();
UTF8Encoding utf = new UTF8Encoding();
Encoder e = utf.GetEncoder();
int count1 =
e.GetByteCount(cAry,0,cAry.Length-4,false);
int count2 =
e.GetByteCount(cAry,cAry.Length-4,4,true);
byte[] bytes1 = new byte[count1];
byte[] bytes2 = new byte[count2];
e.GetBytes(cAry,0,cAry.Length-4,bytes1,0,false);
e.GetBytes(cAry,cAry.Length-4,4,bytes2,0,true);
Console.Write("Bytes1: ");
foreach (byte b in bytes1)
Console.Write(" '{0}' ", b);
Console.WriteLine();
Console.Write("Bytes2: ");
foreach (byte b in bytes2)
Console.Write(" '{0}' ", b);
Console.WriteLine();
}
}
</code>
<para>The output is</para>
<c>
<para>Bytes1: '69' '110' '99' </para>
<para>Bytes2: '111' '100' '101' '114'</para>
</c>
</example>
</Docs>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Members>
<Member MemberName="GetBytes">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual abstract int32 GetBytes(class System.Char[] chars, int32 charIndex, int32 charCount, class System.Byte[] bytes, int32 byteIndex, bool flush)" />
<MemberSignature Language="C#" Value="public abstract int GetBytes (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char[]" />
<Parameter Name="charIndex" Type="System.Int32" />
<Parameter Name="charCount" Type="System.Int32" />
<Parameter Name="bytes" Type="System.Byte[]" />
<Parameter Name="byteIndex" Type="System.Int32" />
<Parameter Name="flush" Type="System.Boolean" />
</Parameters>
<Docs>
<summary>
<para> Encodes the specified range of the specified array
of characters into the specified range of the specified array of bytes. </para>
</summary>
<param name="chars">A <see cref="T:System.Char" /> array of characters to encode. </param>
<param name="charIndex">A <see cref="T:System.Int32" /> that specifies the first index of <paramref name="chars" /> to encode. </param>
<param name="charCount">A <see cref="T:System.Int32" /> that specifies the number of elements in <paramref name="chars" /> to encode. </param>
<param name="bytes">A <see cref="T:System.Byte" /> array to encode into. </param>
<param name="byteIndex">A <see cref="T:System.Int32" /> that specifies the first index of <paramref name="bytes" /> to encode into. </param>
<param name="flush">
<para>A <see cref="T:System.Boolean" /> value. Specify <see langword="true" /> to flush the internal state of the current instance following a conversion; otherwise, specify <see langword="false" /> . <block subset="none" type="note">To ensure correct termination of a sequence of blocks of encoded bytes, it is recommended that the last call to <see cref="M:System.Text.Encoder.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32,System.Boolean)" /> specify <see langword="true" /> .</block></para>
</param>
<returns>
<para> A <see cref="T:System.Int32" /> containing the number of bytes encoded into <paramref name="bytes" /> for a
particular encoding.
</para>
</returns>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="bytes" /> does not contain sufficient space to store the encoded characters.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<para>
<paramref name="chars " />is <see langword="null" /> . </para>
<para>-or- </para>
<para>
<paramref name="bytes " />is <see langword="null" /> . </para>
</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<para>
<paramref name="charIndex" /> < 0. </para>
<para> -or- </para>
<para>
<paramref name="charCount " /> < 0. </para>
<para> -or- </para>
<para>
<paramref name="byteIndex " /> < 0. </para>
<para> -or- </para>
<para>(<paramref name="chars" />.Length - <paramref name="charIndex" />) < <paramref name="charCount" />.</para>
<para>-or-</para>
<para>
<paramref name="byteIndex" /> > <paramref name="bytes" />.Length.</para>
</exception>
<remarks>
<para>The encoding takes into account the state in which the
current instance was left following the last call to this method if
<paramref name="flush" /> was specified as <see langword="true" />
for that call.</para>
<para>
<block subset="none" type="behaviors">As described above.</block>
</para>
<para>
<block subset="none" type="overrides">Override
this method to encode the values of an array of <see cref="T:System.Char" /> objects as an array of <see cref="T:System.Byte" /> objects for a particular
encoding.</block>
</para>
<para>
<block subset="none" type="usage">Use this method to encode the values of an array
of <see cref="T:System.Char" /> objects as an array
of <see cref="T:System.Byte" />
objects for a particular encoding.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetByteCount">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual abstract int32 GetByteCount(class System.Char[] chars, int32 index, int32 count, bool flush)" />
<MemberSignature Language="C#" Value="public abstract int GetByteCount (char[] chars, int index, int count, bool flush);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char[]" />
<Parameter Name="index" Type="System.Int32" />
<Parameter Name="count" Type="System.Int32" />
<Parameter Name="flush" Type="System.Boolean" />
</Parameters>
<Docs>
<summary>
<para> Determines the exact number of bytes required to
encode the specified range in the specified array of
characters.
</para>
</summary>
<param name="chars">A <see cref="T:System.Char" /> array of characters to encode. </param>
<param name="index">A <see cref="T:System.Int32" /> that specifies the first index of <paramref name="chars" /> to encode. </param>
<param name="count">A <see cref="T:System.Int32" /> that specifies the number of elements in <paramref name="chars" /> to encode. </param>
<param name="flush">A <see cref="T:System.Boolean" /> value that determines whether the current instance flushes its internal state following a conversion. Specify <see langword="true" /> to flush the internal state of the current instance following a conversion; otherwise, specify <see langword="false" /> . </param>
<returns>
<para>A <see cref="T:System.Int32" /> containing the
number of bytes required to encode the range in <paramref name="chars" /> from
<paramref name="index" /> to
<paramref name=" index" />
+ <paramref name="count" /> for a particular encoding.</para>
<para>
<block subset="none" type="note">This value takes
into account the state in which the current instance was left following the last
call to <see cref="M:System.Text.Encoder.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32,System.Boolean)" />
.</block>
</para>
</returns>
<exception cref="T:System.ArgumentNullException">
<paramref name="chars " /> is <see langword="null" />. </exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<para>Return value is greater than <see cref="F:System.Int32.MaxValue" />. </para>
<para>-or- </para>
<para>
<paramref name="index" /> < 0. </para>
<para> -or- </para>
<para>
<paramref name="count" /> < 0. </para>
<para> -or- </para>
<para>
<paramref name="index" /> and <paramref name="count" /> do not specify a valid range in <paramref name="chars" /> (i.e. (<paramref name="index" /> + <paramref name="count" />) > <paramref name="chars" />.Length).</para>
</exception>
<remarks>
<para> The state of the current instance is not affected by a call to this
method.
</para>
<para>
<block subset="none" type="behaviors">As described
above.</block>
</para>
<para>
<block subset="none" type="overrides">Override this
method to retrieve the exact number of bytes required to encode a
specified range of an array of <see cref="T:System.Char" /> objects
for a particular encoding.</block>
</para>
<para>
<block subset="none" type="usage">Use this method to determine the
exact number of bytes required to encode the specified range of an array
of <see cref="T:System.Char" /> objects for a particular
encoding.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="ILASM" Value="family rtspecialname specialname instance void .ctor()" />
<MemberSignature Language="C#" Value="protected Encoder ();" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters />
<Docs>
<summary>
<para> Constructs a new instance of the <see cref="T:System.Text.Encoder" /> class.
</para>
</summary>
<remarks>
<para>This constructor is called only by classes that inherit from the <see cref="T:System.Text.Encoder" /> class.</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
</Members>
<TypeExcluded>0</TypeExcluded>
</Type>
|