JAVA将中文转换未Unicode(和native2ascii.exe功能相同)

public class Test {

	public static void main(String[] args) {
		String str = "你好!";
		String unicode = "";

		char[] charAry = new char[str.length()];

		for (int i = 0; i < charAry.length; i++) {
			charAry[i] = (char) str.charAt(i);
			unicode += "\\u" + Integer.toHexString(charAry[i]);
		}
		
		System.out.println(unicode);

	}

}
 

你可能感兴趣的:(java,unicode,native2ascii)