See Also: CharsetEncoder Members
Transforms a sequence of 16-bit Java characters to a byte sequence in some encoding.
The input character sequence is a Java.Nio.CharBuffer and the output byte sequence is a Java.Nio.ByteBuffer.
Use CharsetEncoder.Encode(Java.Nio.CharBuffer) to encode an entire CharBuffer to a new ByteBuffer, or CharsetEncoder.Encode(Java.Nio.CharBuffer, Java.Nio.ByteBuffer, Java.Nio.ByteBuffer) for more control. When using the latter method, the entire operation proceeds as follows:
There are two classes of encoding error: malformed input signifies that the input character sequence is not legal, while unmappable character signifies that the input is legal but cannot be mapped to a byte sequence (because the charset cannot represent the character, for example).
Errors can be handled in three ways. The default is to CodingErrorAction.Report the error to the caller. The alternatives are to CodingErrorAction.Ignore the error or CodingErrorAction.Replace the problematic input with the byte sequence returned by CharsetEncoder.Replacement. The disposition for each of the two kinds of error can be set independently using the CharsetEncoder.OnMalformedInput(CodingErrorAction) and CharsetEncoder.OnUnmappableCharacter(CodingErrorAction) methods.
The default replacement bytes depend on the charset but can be overridden using the CharsetEncoder.ReplaceWith(Byte[]) method.
This class is abstract and encapsulates many common operations of the encoding process for all charsets. Encoders for a specific charset should extend this class and need only to implement the CharsetEncoder.EncodeLoop(Java.Nio.CharBuffer, Java.Nio.ByteBuffer) method for basic encoding. If a subclass maintains internal state, it should also override the CharsetEncoder.ImplFlush(Java.Nio.ByteBuffer) and CharsetEncoder.ImplReset methods.
This class is not thread-safe.