Java Utililty Methods Char to Unicode

List of utility methods to do Char to Unicode

Description

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

Method

voidcharToUnicode(char c)
char To Unicode
System.out.println(Integer.toHexString(("" + c).codePointAt(0)));
StringcharToUnicodeEscape(char c)
Convert a character to its corresponding Unicode escape sequence.
return charToUnicodeEscape(c, new StringBuilder());
StringcharToUnicodeLiteral(int value)
char To Unicode Literal
String sTemp = Integer.toHexString(value);
sTemp = ("0000" + sTemp).substring(sTemp.length());
return "\\u" + sTemp;
voidcharToUnicodeSequence(final StringBuilder buf, final char ch)
char To Unicode Sequence
buf.append("\\u");
buf.append(toHex((ch >> 12) & MAX_HEX_DIGIT));
buf.append(toHex((ch >> 8) & MAX_HEX_DIGIT));
buf.append(toHex((ch >> 4) & MAX_HEX_DIGIT));
buf.append(toHex(ch & MAX_HEX_DIGIT));
bytecharToUtf8(char ch, byte[] bytes, int start)
char To Utf
int codePoint = (int) ch;
if (codePoint <= 0x007F) {
    bytes[start] = (byte) codePoint;
    return 1;
} else if (codePoint <= 0x07FF) {
    bytes[start++] = (byte) (3 << 6 | codePoint >>> 6);
    bytes[start] = (byte) (128 | (byte) (codePoint & 0x3F));
    return 2;
...
StringtoGreek(char c)
Return the unicode representation of a letter in the greek alphabet, where 'a' correspond to 'alpha', 'b' to 'beta' and so on
StringBuilder txt = new StringBuilder();
if (Character.isLetter(c))
    txt.appendCodePoint(945 + c - 'a');
else
    txt.append(c);
return txt.toString();