| 1 |
/* |
| 2 |
* To change this license header, choose License Headers in Project Properties. |
| 3 |
* To change this template file, choose Tools | Templates |
| 4 |
* and open the template in the editor. |
| 5 |
*/ |
| 6 |
|
| 7 |
|
| 8 |
/** |
| 9 |
* |
| 10 |
* @author Jens Deters |
| 11 |
*/ |
| 12 |
public class Test { |
| 13 |
|
| 14 |
public static void main(String[] args) { |
| 15 |
|
| 16 |
String ucStr1 = "U+1F600"; |
| 17 |
String uc = toCode(ucStr1); |
| 18 |
System.out.println(uc); |
| 19 |
|
| 20 |
String ucStr2 = "U+1f478"; |
| 21 |
String ucStr3 = "U+1f3fb"; |
| 22 |
String uc2 = toCode(ucStr2, ucStr3); |
| 23 |
System.out.println(uc2); |
| 24 |
} |
| 25 |
|
| 26 |
public static String toCode(String uccodepoint) { |
| 27 |
int code = Integer.parseInt(uccodepoint.substring(2), 16); |
| 28 |
char[] chars = Character.toChars(code); |
| 29 |
return String.format("\\u%04x\\u%04x", (int)chars[0],(int)chars[1]); |
| 30 |
} |
| 31 |
public static String toCode(String cp1, String cp2) { |
| 32 |
return toCode(cp1).concat(toCode(cp2)); |
| 33 |
} |
| 34 |
} |