com.arsdigita.util
Class Encoding

java.lang.Object
  extended bycom.arsdigita.util.Encoding

public final class Encoding
extends Object

A collection of utility methods for manipulating character and byte data.

Since:
2003-11-15
Version:
$Revision: #3 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Vadim Nasardinov (vadimn@redhat.com)

Nested Class Summary
static class Encoding.UnsupportedException
          This is an unchecked exception.
 
Method Summary
static byte[] getBytes(char ch, String enc)
          Returns the byte representation of the character ch in the specified encoding enc.
static boolean isSupportedEncoding(String enc)
          Returns true if the character encoding enc is supported by the host JVM.
static String toHex(byte b)
          Returns the hexadecimal representation of the byte, with the return value ranging from "0x00" to "0xFF".
static String toHex(char ch)
          Returns the hexadecimal representation of the character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toHex

public static String toHex(char ch)
Returns the hexadecimal representation of the character.

For example, toHex('?') is "0x0C03" and toHex('A') is "0x0041".


toHex

public static String toHex(byte b)
Returns the hexadecimal representation of the byte, with the return value ranging from "0x00" to "0xFF".

For example, toHex((byte) 126) is "0x7E" and toHex((byte) -2) is "0xFE".


isSupportedEncoding

public static boolean isSupportedEncoding(String enc)
Returns true if the character encoding enc is supported by the host JVM.


getBytes

public static byte[] getBytes(char ch,
                              String enc)
Returns the byte representation of the character ch in the specified encoding enc. If the specified encoding is "UTF-16", the result is a platform-dependent two-byte sequence, with the byte-order mark (BOM) stripped out.

Throws:
Encoding.UnsupportedException


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC