Here you can find the source of toUnicode(String s)
public static String toUnicode(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static String toUnicode(String s) { //if (s.length() != 1) throw new RuntimeException("toUnicode input must be a single character"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); ++i) sb.append(toUnicode(s.charAt(i))); return sb.toString(); }/*from w w w. j a v a 2s. co m*/ public static String toUnicode(char c) { return "\\u" + Integer.toHexString(c | 0x10000).substring(1); } }