|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcryptix.mime.LegacyString
This class contains static functions useful in converting between Strings and byte arrays. The name of this class is to remind you that there are better ways of performing such conversions these days - Java 1.1 supplies its own byte-to-char converters, and the Reader and Writer classes take care of most of the more finicky details in a much better way than is done here. Nonetheless, this class exists in order to maintain backwards compatibility with entities which were written before the advent of Java and Unicode.
Note that class contains only static functions, and has no public constructor.
Copyright © 1995-1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.2 $
Method Summary | |
static byte[] |
toByteArray(java.lang.String s)
Equivalent to toByteArray(s, 0, s.length()) . |
static byte[] |
toByteArray(java.lang.String s,
int offset,
int length)
Converts a String to an ISO-Latin-1 encoded byte array. |
static byte[] |
toByteArrayLossless(java.lang.String s)
This method is similar to toByteArray(s) ,
but throws an IllegalArgumentException if any of the
characters in s are outside the range \u0000 to \u00FF. |
static byte[] |
toByteArrayLossless(java.lang.String s,
int offset,
int length)
This method is similar to toByteArray(s, offset, length) ,
but throws an IllegalArgumentException if any of the
characters in s are outside the range \u0000 to \u00FF. |
static java.lang.String |
toString(byte[] b)
Equivalent to toString(b, 0, b.length) . |
static java.lang.String |
toString(byte[] b,
int offset,
int length)
Converts an ISO-Latin-1 encoded byte array to a String. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static byte[] toByteArray(java.lang.String s, int offset, int length)
This conversion function is neccessary because Java 1.1+ uses machine dependent char-to-byte and byte-to-char conversions. This is normally a useful feature, allowing machine independence. In order to maintain backwards compatibility with pre-Java conventions, we implement our own machine-independent deterministic converter.
s
- the string to be converted to bytes.offset
- the character offset within the string to start at.length
- the number of characters to be converted.
public static byte[] toByteArray(java.lang.String s)
toByteArray(s, 0, s.length())
.
public static byte[] toByteArrayLossless(java.lang.String s, int offset, int length)
toByteArray(s, offset, length)
,
but throws an IllegalArgumentException if any of the
characters in s are outside the range \u0000 to \u00FF.
s
- the string to be converted to bytes.offset
- the character offset within the string to start at.length
- the number of characters to be converted.
java.lang.IllegalArgumentException
- if any of the characters in s are out of range.public static byte[] toByteArrayLossless(java.lang.String s)
toByteArray(s)
,
but throws an IllegalArgumentException if any of the
characters in s are outside the range \u0000 to \u00FF.
s
- the string to be converted to bytes.
java.lang.IllegalArgumentException
- if any of the characters in s are out of range.public static java.lang.String toString(byte[] b, int offset, int length)
This conversion function is neccessary because Java 1.1+ uses machine dependent char-to-byte and byte-to-char conversions. This is normally a useful feature, allowing machine independence. In order to maintain backwards compatibility with pre-Java conventions, we implement our own machine-independent deterministic converter.
b
- an array of bytes to be converted to a String.offset
- the character offset within the string to start at.length
- the number of characters to be converted.
public static java.lang.String toString(byte[] b)
toString(b, 0, b.length)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |