com.sun.cldc.i18n.j2me
Class UTF8_Reader
java.lang.Object
java.io.Reader
com.sun.cldc.i18n.StreamReader
com.sun.cldc.i18n.j2me.UTF8_Reader
public class UTF8_Reader
- extends StreamReader
Provides UTF-8 decoding.
- See Also:
- RFC 2279, "UTF-8, a transformation format of ISO 10646",
Adding a Character Encoding,
Porting the User Message Bundle Service
|
Constructor Summary |
UTF8_Reader()
Creates a new reader for UTF-8 encoded streams. |
|
Method Summary |
int |
read()
Reads a single character. |
int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array. |
int |
sizeOf(byte[] array,
int offset,
int length)
Gets the size in chars of an array of bytes. |
UTF8_Reader
public UTF8_Reader()
- Creates a new reader for UTF-8 encoded streams.
read
public int read()
throws IOException
- Reads a single character.
- Overrides:
read in class Reader
- Returns:
- The character read, as an integer in the range 0 to 65535
(0x00-0xffff), or -1 if the end of the stream has
been reached
- Throws:
IOException - if an I/O error occurred.
read
public int read(char[] cbuf,
int off,
int len)
throws IOException
- Reads characters into a portion of an array.
- Specified by:
read in class Reader
- Parameters:
cbuf - Destination bufferoff - Offset at which to start storing characterslen - Maximum number of characters to read
- Returns:
- The number of characters read, or -1 if the end of the
stream has been reached
- Throws:
IOException - if an I/O error occurred.
sizeOf
public int sizeOf(byte[] array,
int offset,
int length)
- Gets the size in chars of an array of bytes.
- Specified by:
sizeOf in class StreamReader
- Throws:
RuntimeException - if the encoding is bad. Unfortunately,
there's really no defined provision for invalid bytes, or for
encoded characters that span more than one sizeOf
call. i.e. characters that are encoded with two or more bytes.
Thus, we are forced to use an exception of this type.
Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.