lejos.charset
Class UTF8Encoder

java.lang.Object
  extended by lejos.charset.UTF8Encoder
All Implemented Interfaces:
CharsetEncoder

public class UTF8Encoder
extends Object
implements CharsetEncoder


Constructor Summary
UTF8Encoder()
           
 
Method Summary
 int encode(int codepoint, byte[] target, int offset)
          Writes the encoding of the codepoint to the byte-array.
 int estimateByteCount(int codepoint)
          Return the number of bytes needed to encode the given codepoint.
 int getMaxCharLength()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8Encoder

public UTF8Encoder()
Method Detail

getMaxCharLength

public int getMaxCharLength()
Specified by:
getMaxCharLength in interface CharsetEncoder

encode

public int encode(int codepoint,
                  byte[] target,
                  int offset)
Description copied from interface: CharsetEncoder
Writes the encoding of the codepoint to the byte-array. The codepoint may be -1 to indicate an undecodable codepoint.

Specified by:
encode in interface CharsetEncoder
Parameters:
codepoint - the character to encode
target - target byte array
offset - index of first byte
Returns:
the offset for the next character

estimateByteCount

public int estimateByteCount(int codepoint)
Description copied from interface: CharsetEncoder
Return the number of bytes needed to encode the given codepoint. The value returned must not be an underestimation.

Specified by:
estimateByteCount in interface CharsetEncoder
Parameters:
codepoint - the Unicode codepoint
Returns:
the estimated number of bytes