1、安装JDK
2、找到JDK里面的native2ascii.exe文件,如图
3、输入汉字,点击回车,即可将汉字转为对应的unicode编码
4、或者打开MyE罕铞泱殳clipse,输入以下JAVA代码,则也可以将汉字转为对应的unicode编码,如图pub造婷用痃lic class Test{ public static String getStrUnicode(String inStr) { StringBuffer unicode = new StringBuffer(); char c; int bit; String tmp = null; for (int i = 0; i < inStr.length(); i++) { c = inStr.charAt(i); if (c > 255) { unicode.append("\\u"); bit = (c >>> 8); tmp = Integer.toHexString(bit); if (tmp.length() == 1) unicode.append("0"); unicode.append(tmp); bit = (c & 0xFF); tmp = Integer.toHexString(bit); if (tmp.length() == 1) unicode.append("0"); unicode.append(tmp); } else { unicode.append(c); } } return (new String(unicode)); } /** * 测试类 */ public static void main(String[] args) { String str = "Hello 中国"; System.out.println("转码前:" + str); System.out.println("转码后:" + getStrUnicode(str)); }}