PenProfile 2.x

com.sun.cldc.i18n.j2me
Class UTF8_Writer

java.lang.Object
  extended by java.io.Writer
      extended by com.sun.cldc.i18n.StreamWriter
          extended by com.sun.cldc.i18n.j2me.UTF8_Writer

public class UTF8_Writer
extends StreamWriter

Encodes characters in UTF-8. This does not support writing characters that directly require more than 3 UTF-8 encoded bytes. Surrogates, however, are supported.

Any unencodable characters are replaced in the stream with '?'.

See Also:
RFC 2279, "UTF-8, a transformation format of ISO 10646"

Field Summary
 
Fields inherited from class com.sun.cldc.i18n.StreamWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
UTF8_Writer()
          Creates a new writer for UTF-8 encoded streams.
 
Method Summary
 void close()
          Closes the writer.
 Writer open(OutputStream out, String enc)
          Opens the writer.
 int sizeOf(char[] array, int offset, int length)
          Gets the size in bytes of an array of chars.
 void write(char[] cbuf, int off, int len)
          Writes a portion of an array of characters.
 void write(int c)
          Writes a single character.
 
Methods inherited from class com.sun.cldc.i18n.StreamWriter
flush
 
Methods inherited from class java.io.Writer
write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8_Writer

public UTF8_Writer()
Creates a new writer for UTF-8 encoded streams.

Method Detail

write

public void write(int c)
           throws IOException
Writes a single character.

Overrides:
write in class Writer
Parameters:
c - int specifying a character to be written
Throws:
IOException - if an I/O error occurs.

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Writes a portion of an array of characters.

Specified by:
write in class Writer
Parameters:
cbuf - array of characters
off - offset from which to start writing characters
len - number of characters to write
Throws:
IOException - if an I/O error occurs.

open

public Writer open(OutputStream out,
                   String enc)
            throws UnsupportedEncodingException
Opens the writer.

Overrides:
open in class StreamWriter
Parameters:
out - the output stream
enc - the character encoding
Returns:
the new writer
Throws:
UnsupportedEncodingException - if specified encoding is not supported.

close

public void close()
           throws IOException
Closes the writer.

Overrides:
close in class StreamWriter
Throws:
IOException - if there was an I/O error while closing.

sizeOf

public int sizeOf(char[] array,
                  int offset,
                  int length)
Gets the size in bytes of an array of chars. This assumes surrogate pairs do not cross character array boundaries.

Specified by:
sizeOf in class StreamWriter

PenProfile 2.x

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