ref_send API 2.17
defensive programming in Java

org.joe_e.charset
Class UTF8

java.lang.Object
  extended by org.joe_e.charset.UTF8

public final class UTF8
extends java.lang.Object

UTF-8 I/O.


Method Summary
static java.lang.String decode(byte[] buffer)
          Decodes a UTF-8 string.
static java.lang.String decode(byte[] buffer, int off, int len)
          Decodes a UTF-8 string.
static byte[] encode(java.lang.String text)
          Encodes a string in UTF-8.
static java.io.Reader input(java.io.InputStream in)
          Constructs a UTF-8 reader.
static java.io.Writer output(java.io.OutputStream out)
          Constructs a UTF-8 writer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static byte[] encode(java.lang.String text)
Encodes a string in UTF-8.

Parameters:
text - The text to encode.
Returns:
The UTF-8 bytes.

decode

public static java.lang.String decode(byte[] buffer)
Decodes a UTF-8 string. Each byte not corresponding to a UTF-8 character decodes to the Unicode replacement character U+FFFD. Note that an initial byte-order mark is not stripped. This method is equivalent to decode(buffer, 0, buffer.length).

Parameters:
buffer - the ASCII-encoded string to decode
Returns:
The corresponding string
Throws:
java.lang.IndexOutOfBoundsException

decode

public static java.lang.String decode(byte[] buffer,
                                      int off,
                                      int len)
Decodes a UTF-8 string. Each byte not corresponding to a UTF-8 character decodes to the Unicode replacement character U+FFFD. Note that an initial byte-order mark is not stripped.

Parameters:
buffer - the ASCII-encoded string to decode
off - where to start decoding
len - how many bytes to decode
Returns:
The corresponding string
Throws:
java.lang.IndexOutOfBoundsException

input

public static java.io.Reader input(java.io.InputStream in)
Constructs a UTF-8 reader.

Parameters:
in - The binary input stream.

output

public static java.io.Writer output(java.io.OutputStream out)
Constructs a UTF-8 writer.

Parameters:
out - The binary output stream.

ref_send API 2.17
defensive programming in Java

Submit a bug or feature, or get help

Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.