Here you can find the source of toUnicodeEscape(char c)
Parameter | Description |
---|---|
c | input char |
"\\uXXXX"
, where XXXX are hexadecimal digits, always zero-padded.
public static String toUnicodeEscape(char c)
//package com.java2s; public class Main { private static final char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /**/*from www . jav a2 s. c o m*/ * Encode a single char in Unicde BMP as a Java Unicode escape sequence. * @param c input char * @return string on the form <code>"\\uXXXX"</code>, where XXXX are hexadecimal * digits, always zero-padded. */ public static String toUnicodeEscape(char c) { 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); } }