Java Utililty Methods Unicode Create

List of utility methods to do Unicode Create

Description

The list of methods to do Unicode Create are organized into topic(s).

Method

StringtoUnicode(String text)
Unicode????
StringBuffer strBuffer = new StringBuffer();
if (text == null) {
    return "";
char[] cArray = text.toCharArray();
final int cArrayLength = cArray.length;
strBuffer.delete(0, strBuffer.length());
String hexStr;
...
StringtoUnicode(String theString, boolean escapeSpace)
to Unicode
int len = theString.length();
int bufLen = len * 2;
if (bufLen < 0) {
    bufLen = Integer.MAX_VALUE;
StringBuffer outBuffer = new StringBuffer(bufLen);
for (int x = 0; x < len; x++) {
    char aChar = theString.charAt(x);
...
StringtoUnicode(String value)
to Unicode
if (value == null) {
    return value;
String result = ""; 
for (int i = 0; i < value.length(); i++) {
    char character = value.charAt(i);
    if (character == '>') {
        result += "&gt;"; 
...
voidtoUnicode(StringBuilder strBuilder, char ch)
to Unicode
strBuilder.append("\\u");
for (int i = 4; i > 0; i--) {
    strBuilder.append(hexs[(ch & 0xf000) >> 12]);
    ch <<= 4;
byte[]toUnicodeBytes(String str)
to Unicode Bytes
byte[] unicodeBytes = null;
try {
    byte[] unicodeBytesWithQuotes = str.getBytes("Unicode");
    unicodeBytes = new byte[unicodeBytesWithQuotes.length - 2];
    System.arraycopy(unicodeBytesWithQuotes, 2, unicodeBytes, 0, unicodeBytesWithQuotes.length - 2);
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
return unicodeBytes;
StringtoUnicodeEncoded(String data)
to Unicode Encoded
final int unicodeSize = 4;
StringBuilder sb = new StringBuilder();
if (data != null) {
    int l = data.length();
    for (int i = 0; i < l; i++) {
        if (data.charAt(i) >= MINIMUM_UNICODE) {
            sb.append("\\u");
            String s = Integer.toHexString((int) data.charAt(i));
...
StringtoUnicodeEscape(char c)
Encode a single char in Unicde BMP as a Java Unicode escape sequence.
char[] result = { '\\', 'u', 0, 0, 0, 0 };
result[2] = HEX[(c >>> 12) & 0xF];
result[3] = HEX[(c >>> 8) & 0xF];
result[4] = HEX[(c >>> 4) & 0xF];
result[5] = HEX[c & 0xF];
return new String(result);
StringtoUnicodeEscape(int ch)
to Unicode Escape
return "\\u" + String.format("%04X", ch);
StringtoUnicodeLiteral(String s)
to Unicode Literal
StringBuffer result = new StringBuffer();
char[] carr = s.toCharArray();
String unicode;
for (int i = 0; i < carr.length; i++) {
    result.append("\\u");
    unicode = Integer.toHexString(carr[i]).toUpperCase();
    for (int j = 4 - unicode.length(); j > 0; j--) {
        result.append("0");
...
StringtoUnicodePoint(char c)
to Unicode Point
StringBuffer sb = new StringBuffer(5);
for (int i = 3; i >= 0; i--) {
    sb.append(Character.forDigit((c >> (4 * i)) & 15, 16));
return sb.toString();