public class StringUnicodeEncoderDecoder
extends java.lang.Object
Constructor and Description |
---|
StringUnicodeEncoderDecoder() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decodeUnicodeSequenceToString(java.lang.String unicodeSequence)
This method converts
String that contains a sequence of Unicode codes onto a String of corresponding characters. |
static java.lang.String |
encodeStringToUnicodeSequence(java.lang.String txt)
This method converts a
String of characters in any language into a String That contains a sequence of Unicode codes corresponding to
characters in the original String For Example String "Hello" will be converted into a String "\u0048\u0065\u006c\u006c\u006f" Null or empty
String conversion will return an empty String |
public static java.lang.String encodeStringToUnicodeSequence(java.lang.String txt)
String
of characters in any language into a String That contains a sequence of Unicode codes corresponding to
characters in the original String For Example String "Hello" will be converted into a String "\u0048\u0065\u006c\u006c\u006f" Null or empty
String conversion will return an empty Stringtxt
- String
that contains a sequence of characters to convertString
That contains a sequence of unicode codes corresponding to the characters in the original String. Each code will be in
hexadecimal format preceded by prefix "\u" with no spaces between them. The String also will have no leading or trailing
white spacespublic static java.lang.String decodeUnicodeSequenceToString(java.lang.String unicodeSequence) throws java.lang.IllegalArgumentException
String
that contains a sequence of Unicode codes onto a String of corresponding characters. For example a String
"\u0048\u0065\u006c\u006c\u006f" will be converted into String "Hello" by this method. This method performs reverse conversion of the one
performed by method encodeStringToUnicodeSequence(String)
I.e. Any textual String converted into sequence of Unicode codes by method
encodeStringToUnicodeSequence(String)
may be retrieved back by invoking this method on that Unicode sequence String.unicodeSequence
- String
That contains sequence of Unicode codes. Each code must be in hexadecimal format and must be preceded by
"'backslash' + 'u'" prefix. (note that prefix '\U' is now valid as opposed to earlier versions). This method allows
leading and trailing whitespaces for the whole String as well as spaces between codes. Those white spaces will be ignored.String
That contains sequence of characters that correspond to the respective Unicode codes in the original Stringjava.lang.IllegalArgumentException
- if input String is in invalid format. For example if any code is not in hexadecimal format or the code is not a valid Unicode code
(not valid code point).