Java Unicode unicode(StringBuilder buf, char c)

Here you can find the source of unicode(StringBuilder buf, char c)

Description

Represent as unicode

License

Open Source License

Parameter

Parameter Description
c character to be encoded

Declaration

private static void unicode(StringBuilder buf, char c) 

Method Source Code

//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;
        }
    }
}

Related

  1. unicode(String ipStr)
  2. unicode(String s)
  3. Unicode2ASCII(String unicode)
  4. unicode2Byte(String s)
  5. Unicode2GBK(String dataStr)
  6. unicode2native(String s)