oracle.portal.utils.v1
Class MultiByteEncoder

java.lang.Object
  |
  +--oracle.portal.utils.v1.MultiByteEncoder

public class MultiByteEncoder
extends java.lang.Object

The class contains a utility method for encoding an arbitrary String using the set of characters allowed in a URI, as defined in RFC 2396 - "Uniform Resource Identifiers (URI): Generic Syntax". The method does not suffer from the limitations of the java.net.URLEncoder in that it provides control over the character encoding used for character to byte conversions and is capable of encoding characters that are encoded by a sequence of several bytes.

To convert a String, each character is examined in turn:


Constructor Summary
MultiByteEncoder()
           
 
Method Summary
static java.lang.String encode(java.lang.String value, java.lang.String encoding)
          Encodes a String using the set of characters allowed in a URI.
static java.lang.String encodeUTF(java.lang.String value)
          Encodes a String using the set of characters allowed in a URI.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiByteEncoder

public MultiByteEncoder()
Method Detail

encode

public static java.lang.String encode(java.lang.String value,
                                      java.lang.String encoding)
                               throws java.io.UnsupportedEncodingException
Encodes a String using the set of characters allowed in a URI.
Parameters:
value - String to be translated.
encoding - the IANA character encoding to be used to convert non-ASCII characters into bytes (e.g. "UTF-8").
Returns:
the translated String.
Throws:
java.io.UnsupportedEncodingException - if the given encoding is not a supported IANA character encoding.

encodeUTF

public static java.lang.String encodeUTF(java.lang.String value)
Encodes a String using the set of characters allowed in a URI. This method encodes a multibyte string in UTF-8
Parameters:
value - String to be translated.
Returns:
the translated String.