Encoding | CF 1.0, ECMA 1.0, serializable |
System.Text (mscorlib.dll) | abstract class |
This class converts strings of Unicode
characters to and from byte arrays.
Derived classes implement specific encoding types. The
GetBytes( ) method takes an array of characters
and returns the corresponding array of bytes. The GetChars(
) method does the opposite conversion.
GetByteCount( ) and GetCharCount(
) allow you to get the exact size of the encoding or
decoding to size the output buffer appropriately.
The GetEncoder( ) and GetDecoder(
) methods create Encoder and
Decoder instances that allow you to do encoding
across sequential blocks in which partial byte codes may remain in
the buffer.
public abstract class Encoding {
// Protected Constructors
protected Encoding( );
protected Encoding(int codePage);
// Public Static Properties
public static Encoding ASCII{get; }
public static Encoding BigEndianUnicode{get; }
public static Encoding Default{get; }
public static Encoding Unicode{get; }
public static Encoding UTF7{get; }
public static Encoding UTF8{get; }
// Public Instance Properties
public virtual string BodyName{get; }
public virtual int CodePage{get; }
public virtual string EncodingName{get; }
public virtual string HeaderName{get; }
public virtual bool IsBrowserDisplay{get; }
public virtual bool IsBrowserSave{get; }
public virtual bool IsMailNewsDisplay{get; }
public virtual bool IsMailNewsSave{get; }
public virtual string WebName{get; }
public virtual int WindowsCodePage{get; }
// Public Static Methods
public static byte[ ] Convert(Encoding srcEncoding, Encoding dstEncoding, byte[ ] bytes);
public static byte[ ] Convert(Encoding srcEncoding, Encoding dstEncoding, byte[ ] bytes,
int index, int count);
public static Encoding GetEncoding(int codepage);
public static Encoding GetEncoding(string name);
// Public Instance Methods
public override bool Equals(object value);
// overrides object
public virtual int GetByteCount(char[ ] chars);
public abstract int GetByteCount(char[ ] chars, int index, int count);
public virtual int GetByteCount(string s);
public virtual byte[ ] GetBytes(char[ ] chars);
public virtual byte[ ] GetBytes(char[ ] chars, int index, int count);
public virtual byte[ ] GetBytes(string s);
public abstract int GetBytes(char[ ] chars, int charIndex, int charCount, byte[ ] bytes,
int byteIndex);
public virtual int GetBytes(string s, int charIndex, int charCount, byte[ ] bytes,
int byteIndex);
public virtual int GetCharCount(byte[ ] bytes);
public abstract int GetCharCount(byte[ ] bytes, int index, int count);
public virtual char[ ] GetChars(byte[ ] bytes);
public virtual char[ ] GetChars(byte[ ] bytes, int index, int count);
public abstract int GetChars(byte[ ] bytes, int byteIndex, int byteCount, char[ ] chars,
int charIndex);
public virtual Decoder GetDecoder( );
public virtual Encoder GetEncoder( );
public override int GetHashCode( );
// overrides object
public abstract int GetMaxByteCount(int charCount);
public abstract int GetMaxCharCount(int byteCount);
public virtual byte[ ] GetPreamble( );
public virtual string GetString(byte[ ] bytes);
public virtual string GetString(byte[ ] bytes, int index, int count);
}
Subclasses
ASCIIEncoding, UnicodeEncoding,
UTF7Encoding, UTF8Encoding
Returned By
System.IO.StreamReader.CurrentEncoding,
System.IO.TextWriter.Encoding,
System.Xml.XmlParserContext.Encoding,
System.Xml.XmlTextReader.Encoding,
System.Xml.XmlValidatingReader.Encoding
Passed To
System.IO.BinaryReader.BinaryReader( ),
System.IO.BinaryWriter.BinaryWriter( ),
System.IO.StreamReader.StreamReader( ),
System.IO.StreamWriter.StreamWriter( ),
System.String.String( ),
System.Xml.XmlParserContext.{Encoding,
XmlParserContext( )},
System.Xml.XmlTextWriter.XmlTextWriter( )
|