PenProfile 2.x

com.sun.cldc.i18n.j2me
Class UTF8_Reader

java.lang.Object
  extended by java.io.Reader
      extended by com.sun.cldc.i18n.StreamReader
          extended by 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

Field Summary
 
Fields inherited from class com.sun.cldc.i18n.StreamReader
in
 
Fields inherited from class java.io.Reader
lock
 
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.
 
Methods inherited from class com.sun.cldc.i18n.StreamReader
close, mark, markSupported, open, ready, reset
 
Methods inherited from class java.io.Reader
read, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8_Reader

public UTF8_Reader()
Creates a new reader for UTF-8 encoded streams.

Method Detail

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 buffer
off - Offset at which to start storing characters
len - 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.

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.