public class

CharToByteUTF8

extends CharToByteConverter
java.lang.Object
   ↳ sun.io.CharToByteConverter
     ↳ sun.io.CharToByteUTF8

Class Overview

UCS2 (UTF16) -> UCS Transformation Format 8 (UTF-8) converter It's represented like below. # Bits Bit pattern 1 7 0xxxxxxx 2 11 110xxxxx 10xxxxxx 3 16 1110xxxx 10xxxxxx 10xxxxxx 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx UCS2 uses 1-3 / UTF16 uses 1-4 / UCS4 uses 1-6

Summary

[Expand]
Inherited Fields
From class sun.io.CharToByteConverter
Public Constructors
CharToByteUTF8()
Public Methods
boolean canConvert(char ch)
Returns true if the given character can be converted to the target character encoding.
int convert(char[] input, int inOff, int inEnd, byte[] output, int outOff, int outEnd)
Character conversion
int flush(byte[] output, int outStart, int outEnd)
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.
int getMaxBytesPerChar()
Returns the maximum number of bytes needed to convert a char.
void reset()
Resets converter to its initial state.
[Expand]
Inherited Methods
From class sun.io.CharToByteConverter
From class java.lang.Object

Public Constructors

public CharToByteUTF8 ()

Public Methods

public boolean canConvert (char ch)

Returns true if the given character can be converted to the target character encoding.

Parameters
ch character to test
Returns
  • true if given character is translatable, false otherwise.

public int convert (char[] input, int inOff, int inEnd, byte[] output, int outOff, int outEnd)

Character conversion

Parameters
input array containing Unicode characters to be converted.
inOff begin conversion at this offset in input array.
inEnd stop conversion at this offset in input array (exclusive).
output byte 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 (byte[] output, int outStart, int outEnd)

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

Parameters
output byte array to receive flushed output.
outStart start writing to output array at this offset.
outEnd stop writing to output array at this offset (exclusive).

public String getCharacterEncoding ()

Returns the character set id for the conversion.

public int getMaxBytesPerChar ()

Returns the maximum number of bytes needed to convert a char. Useful for calculating the maximum output buffer size needed for a particular input buffer.

public void reset ()

Resets converter to its initial state.