Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

Name

Encoder

Synopsis

Encoding.GetEncoder( ) returns an instance of this type, which converts character arrays to byte arrays using the encoding subclass from which it was constructed. This class exposes the GetBytes( ) method, which converts a sequence of character blocks into a sequence of byte blocks. Since Encoder maintains state between calls to GetBytes( ), it can deal with partial sequences that occur at block boundaries.

The last argument to GetBytes( ) is a boolean that specifies whether the internal buffer is flushed after the method is called. If true, state information on the object is lost between blocks. If false (the default), the buffer is maintained. A call with flushing set to true is needed on the final call to Encoding.GetBytes( ) to close the byte array properly.

public abstract class Encoder {
// Protected Constructors
   protected Encoder( );
// Public Instance Methods
   public abstract int GetByteCount(char[ ] chars, int index,  int count, bool flush);
   public abstract int GetBytes(char[ ] chars, int charIndex, int charCount, byte[ ] bytes, 
        int byteIndex, bool flush);
}

Returned By

Encoding.GetEncoder( )

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Joe Mayo

Publisher Resources

ISBN: 0596005261Catalog PageErrata