public class Convert extends Object
Note regarding UTF-8. The JVMS defines its own version of the UTF-8 format so that it contains no zero bytes (modified UTF-8). This is not actually the same as Charset.forName("UTF-8").
See also:
The methods here support modified UTF-8.This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Constructor and Description |
---|
Convert() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
chars2utf(char[] src)
Return all characters in given array as an array of bytes
in Utf8 representation.
|
static int |
chars2utf(char[] src,
int sindex,
byte[] dst,
int dindex,
int len)
Copy characters in source array to bytes in target array,
converting them to Utf8 representation.
|
static byte[] |
chars2utf(char[] src,
int sindex,
int len)
Return characters as an array of bytes in Utf8 representation.
|
static List<Name> |
enclosingCandidates(Name name) |
static String |
escapeUnicode(String s)
Escape all unicode characters in string.
|
static Name |
packagePart(Name classname)
Return the package name of a class name, excluding the trailing '.',
"" if not existent.
|
static String |
packagePart(String classname) |
static String |
quote(char ch)
Escapes a character if it has an escape sequence or is
non-printable ASCII.
|
static String |
quote(String s)
Escapes each character in a string that has an escape sequence or
is non-printable ASCII.
|
static Name |
shortName(Name classname)
Return the last part of a class name.
|
static String |
shortName(String classname) |
static int |
string2int(String s,
int radix)
Convert string to integer.
|
static long |
string2long(String s,
int radix)
Convert string to long integer.
|
static byte[] |
string2utf(String s)
Return string as an array of bytes in in Utf8 representation.
|
static char[] |
utf2chars(byte[] src)
Return all bytes of a given array in Utf8 representation
as an array of characters.
|
static int |
utf2chars(byte[] src,
int sindex,
char[] dst,
int dindex,
int len)
Convert `len' bytes from utf8 to characters.
|
static char[] |
utf2chars(byte[] src,
int sindex,
int len)
Return bytes in Utf8 representation as an array of characters.
|
static String |
utf2string(byte[] src)
Return all bytes of a given array in Utf8 representation
as a string.
|
static String |
utf2string(byte[] src,
int sindex,
int len)
Return bytes in Utf8 representation as a string.
|
public static int string2int(String s, int radix) throws NumberFormatException
NumberFormatException
public static long string2long(String s, int radix) throws NumberFormatException
NumberFormatException
public static int utf2chars(byte[] src, int sindex, char[] dst, int dindex, int len)
src
- The array holding the bytes to convert.sindex
- The start index from which bytes are converted.dst
- The array holding the converted characters..dindex
- The start index from which converted characters
are written.len
- The maximum number of bytes to convert.public static char[] utf2chars(byte[] src, int sindex, int len)
src
- The array holding the bytes.sindex
- The start index from which bytes are converted.len
- The maximum number of bytes to convert.public static char[] utf2chars(byte[] src)
src
- The array holding the bytes.public static String utf2string(byte[] src, int sindex, int len)
src
- The array holding the bytes.sindex
- The start index from which bytes are converted.len
- The maximum number of bytes to convert.public static String utf2string(byte[] src)
src
- The array holding the bytes.public static int chars2utf(char[] src, int sindex, byte[] dst, int dindex, int len)
src
- The array holding the characters to convert.sindex
- The start index from which characters are converted.dst
- The array holding the converted characters..dindex
- The start index from which converted bytes
are written.len
- The maximum number of characters to convert.public static byte[] chars2utf(char[] src, int sindex, int len)
src
- The array holding the characters.sindex
- The start index from which characters are converted.len
- The maximum number of characters to convert.public static byte[] chars2utf(char[] src)
src
- The array holding the characters.public static byte[] string2utf(String s)
public static String quote(String s)
public static String quote(char ch)
public static Name packagePart(Name classname)
Copyright © 2017 earcam. All rights reserved.