public final class Unicode extends Object
Constructor and Description |
---|
Unicode() |
Modifier and Type | Method and Description |
---|---|
static char |
bytesToChar(byte[] bytes)
Return the Unicode char which is coded in the bytes at position 0.
|
static char |
bytesToChar(byte[] bytes,
int pos)
Return the Unicode char which is coded in the bytes at the given
position.
|
static byte[] |
charToBytes(char car)
Return the Unicode char which is coded in the bytes at the given
position.
|
static int |
countBytes(char[] chars)
Count the number of bytes included in the given char[].
|
static int |
countBytesPerChar(byte[] bytes,
int pos)
Count the number of bytes needed to return an Unicode char.
|
static int |
countChars(byte[] bytes)
Count the number of chars included in the given byte[].
|
static int |
countNbBytesPerChar(char car)
Return the number of bytes that hold an Unicode char.
|
static boolean |
isUnicodeSubset(byte b)
Check if the current byte is in the unicodeSubset : all chars but
'\0', '(', ')', '*' and '\'
|
static boolean |
isUnicodeSubset(char c)
Check if the current char is in the unicodeSubset : all chars but
'\0', '(', ')', '*' and '\'
|
static boolean |
isUnicodeSubset(String str,
int pos)
Check if the current char is in the unicodeSubset : all chars but
'\0', '(', ')', '*' and '\'
|
static String |
readUTF(ObjectInput objectInput)
Reads in a string that has been encoded using a modified UTF-8 format.
|
static void |
writeUTF(ObjectOutput objectOutput,
String str)
Writes four bytes of length information to the output stream, followed by the modified UTF-8 representation
of every character in the string str.
|
public Unicode()
public static int countBytesPerChar(byte[] bytes, int pos)
bytes
- The bytes to readpos
- Position to start counting. It must be a valid start of a
encoded char !public static char bytesToChar(byte[] bytes)
bytes
- The byte[] represntation of an Unicode string.public static char bytesToChar(byte[] bytes, int pos)
bytes
- The byte[] represntation of an Unicode string.pos
- The current position to start decoding the charpublic static int countNbBytesPerChar(char car)
car
- The character to be decodedpublic static int countBytes(char[] chars)
chars
- The char array to decodepublic static int countChars(byte[] bytes)
bytes
- The byte array to decodepublic static byte[] charToBytes(char car)
car
- The character to be transformed to an array of bytespublic static boolean isUnicodeSubset(String str, int pos)
str
- The string to checkpos
- Position of the current charpublic static boolean isUnicodeSubset(char c)
c
- The char to checkpublic static boolean isUnicodeSubset(byte b)
b
- The byte to checkpublic static void writeUTF(ObjectOutput objectOutput, String str) throws IOException
DataOutput.writeUTF(String)
.objectOutput
- The objectOutput to write tostr
- The value to writeIOException
- If the value can't be written to the filepublic static String readUTF(ObjectInput objectInput) throws IOException
DataInput.readUTF()
.objectInput
- The objectInput to read fromIOException
- If the value can't be readCopyright © 2003–2014 The Apache Software Foundation. All rights reserved.