Here you can find the source of toUnicodeSymbols(String s)
Parameter | Description |
---|---|
s | the specified string |
public static String toUnicodeSymbols(String s)
//package com.java2s; public class Main { /**/* w ww .j a v a 2 s .co m*/ * Translate the specified string to UNICODE presented code string. * * @param s * the specified string * @return UNICODE presented code string */ public static String toUnicodeSymbols(String s) { StringBuffer sb = new StringBuffer(); char a[] = s.toCharArray(); for (char c : a) if (c < 256) sb.append(c); else if (c < 4096) sb.append(String.format("\\u0%h", (int) c));//$NON-NLS-1$ else sb.append(String.format("\\u%h", (int) c));//$NON-NLS-1$ return sb.toString(); } }