lejos.charset
Class Latin1Decoder
java.lang.Object
lejos.charset.Latin1Decoder
- All Implemented Interfaces:
- CharsetDecoder
public class Latin1Decoder
- extends Object
- implements CharsetDecoder
Method Summary |
int |
decode(byte[] buf,
int offset,
int limit)
Calculates a Unicode codepoint from the bytes in the buffer. |
int |
estimateByteCount(byte[] buf,
int offset,
int limit)
Calculates the number of bytes that are needed to decode a full Unicode codepoint
at the given position in the byte array. |
int |
getMaxCharLength()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Latin1Decoder
public Latin1Decoder()
decode
public int decode(byte[] buf,
int offset,
int limit)
- Description copied from interface:
CharsetDecoder
- Calculates a Unicode codepoint from the bytes in the buffer.
If the bytes in the buffer cannot be decoded, because they are
malformed or because there is not enough data, then the '?' character
should be returned.
- Specified by:
decode
in interface CharsetDecoder
- Parameters:
buf
- the array of bytesoffset
- the index of the first byte to be readlimit
- the index after the last byte that is to be read
- Returns:
- the Unicode codepoint or '?'
estimateByteCount
public int estimateByteCount(byte[] buf,
int offset,
int limit)
- Description copied from interface:
CharsetDecoder
- Calculates the number of bytes that are needed to decode a full Unicode codepoint
at the given position in the byte array.
The function must handle three cases:
a) the given array does contain the full encoding of a Unicode codepoint
b) the given data is too short to be the encoding of a Unicode codepoint
c) the given data is malformed
In cases a) and c), the function must return the number of
bytes that must be skipped after the decoding of the character.
In case b), the function should return an estimation of the
number of bytes needed to decode the next Unicode codepoint.
Yet, this must not be an overestimation. In case b), the return
value should be at least (limit - offset + 1).
- Specified by:
estimateByteCount
in interface CharsetDecoder
- Parameters:
buf
- the array of bytesoffset
- the index of the first byte to be readlimit
- the index after the last byte that is to be read
- Returns:
- the estimated number of bytes
getMaxCharLength
public int getMaxCharLength()
- Specified by:
getMaxCharLength
in interface CharsetDecoder