Java Unicode Create toUnicodeStr(int i)

Here you can find the source of toUnicodeStr(int i)

Description

to Unicode Str

License

Open Source License

Declaration

public static String toUnicodeStr(int i) 

Method Source Code

//package com.java2s;
/*//from   w  ww.  j av  a2  s.c  o  m
 * Xapp (pronounced Zap!), A automatic gui tool for Java.
 * Copyright (C) 2009 David Webber. All Rights Reserved.
 *
 * The contents of this file may be used under the terms of the GNU Lesser
 * General Public License Version 2.1 or later.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 */

public class Main {
    public static String toUnicodeStr(int i) {
        char c1 = Integer.toHexString((i >> 12) & 0x0000000F).charAt(0);
        char c2 = Integer.toHexString((i >> 8) & 0x0000000F).charAt(0);
        char c3 = Integer.toHexString((i >> 4) & 0x0000000F).charAt(0);
        char c4 = Integer.toHexString((i) & 0x0000000F).charAt(0);
        return "\\u" + c1 + c2 + c3 + c4;
    }
}

Related

  1. toUnicodeEscape(char c)
  2. toUnicodeEscape(int ch)
  3. toUnicodeLiteral(String s)
  4. toUnicodePoint(char c)
  5. toUnicodeRepresentation(String str)
  6. toUnicodeString(byte[] ba)
  7. toUnicodeString(byte[] data)
  8. toUnicodeString(char c)
  9. toUnicodeString(char[] chars)