public class

ByteToCharUnicode

extends ByteToCharConverter
java.lang.Object
   ↳ sun.io.ByteToCharConverter
     ↳ sun.io.ByteToCharUnicode
Known Direct Subclasses

Class Overview

Convert byte arrays containing Unicode characters into arrays of actual Unicode characters. This class may be used directly, in which case it expects the input byte array to begin with a byte-order mark, or it may be subclassed in order to preset the byte order and mark behavior.

Whether or not a mark is expected, if a mark that does not match the established byte order is later discovered then a MalformedInputException will be thrown by the convert method. If a correct mark is seen later in the input stream, it is passed through as a character.

Summary

[Expand]
Inherited Fields
From class sun.io.ByteToCharConverter
Public Constructors
ByteToCharUnicode()
Creates a Unicode byte-to-char converter that expects the first pair of input bytes to be a byte-order mark, which will be interpreted and discarded.
Protected Constructors
ByteToCharUnicode(int bo, boolean m)
Creates a Unicode byte-to-char converter that uses the given byte order and may or may not insist upon an initial byte-order mark.
Public Methods
int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
Converts an array of bytes containing characters in an external encoding into an array of Unicode characters.
int flush(char[] buf, int off, int len)
Writes any remaining output to the output buffer and resets the converter to its initial state.
String getCharacterEncoding()
Returns the character set id for the conversion
void reset()
Resets converter to its initial state.
[Expand]
Inherited Methods
From class sun.io.ByteToCharConverter
From class java.lang.Object

Public Constructors

public ByteToCharUnicode ()

Creates a Unicode byte-to-char converter that expects the first pair of input bytes to be a byte-order mark, which will be interpreted and discarded. If the first pair of bytes is not such a mark then a MalformedInputException will be thrown by the convert method.

Protected Constructors

protected ByteToCharUnicode (int bo, boolean m)

Creates a Unicode byte-to-char converter that uses the given byte order and may or may not insist upon an initial byte-order mark.

Public Methods

public int convert (byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)

Converts an array of bytes containing characters in an external encoding into an array of Unicode characters. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. Among other things, this means multibyte input sequences can be split between calls. If a call to convert results in an exception, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method.

Parameters
in byte array containing text to be converted.
inOff begin conversion at this offset in input array.
inEnd stop conversion at this offset in input array (exclusive).
out character array to receive conversion result.
outOff start writing to output array at this offset.
outEnd stop writing to output array at this offset (exclusive).
Returns
  • the number of bytes written to output.

public int flush (char[] buf, int off, int len)

Writes any remaining output to the output buffer and resets the converter to its initial state.

Parameters
buf char array to receive flushed output.
off start writing to output array at this offset.
len stop writing to output array at this offset (exclusive).

public String getCharacterEncoding ()

Returns the character set id for the conversion

public void reset ()

Resets converter to its initial state.