Here you can find the source of unicode(StringBuilder buf, char c)
Parameter | Description |
---|---|
c | character to be encoded |
private static void unicode(StringBuilder buf, char c)
//package com.java2s; public class Main { static char[] hex = "0123456789ABCDEF".toCharArray(); /**//www .j ava 2s .co m * Represent as unicode * * @param c * character to be encoded */ private static void unicode(StringBuilder buf, char c) { buf.append("\\u"); int n = c; for (int i = 0; i < 4; ++i) { int digit = (n & 0xf000) >> 12; buf.append(hex[digit]); n <<= 4; } } }