网站如何在手机上显示,手机设计软件平面设计,做网站的公司一年能赚多少钱,企业网站建设合同范本这两天在使用RBManager#xff08;一个开源工具#xff0c;用于多国化字符转化#xff09;工具的时候觉得很不方便#xff0c;有的时候只需要知道中文对应的unicode码是多少#xff0c;不需要这么麻烦的操作#xff0c;所以就自己写了一个工具#xff0c;专门用于将中文… 这两天在使用RBManager一个开源工具用于多国化字符转化工具的时候觉得很不方便有的时候只需要知道中文对应的unicode码是多少不需要这么麻烦的操作所以就自己写了一个工具专门用于将中文转换成unicode码。1.工具代码如下 Code 1 package ben; 2 3 import java.io.IOException; 4 import java.io.InputStreamReader; 5 import java.io.UnsupportedEncodingException; 6 7 public class Native2Ascii { 8 static String java_bin_path “D:\\jdk1.4.2_03\\bin”; 9 // 存放中文的文本文件10 static String source_file “C \\a.txt”;11 12 public static void main(String[] args) {13 String result getUnicodeString(source_file);14 System.out.println(result);15 }16 17 private static String getUnicodeString(String destFileName) {18 StringBuffer tempSb new StringBuffer();19 try {20 Process p Runtime.getRuntime().exec(java_bin_path “\\native2ascii.exe ” destFileName);21 InputStreamReader child_in new InputStreamReader(p.getInputStream());22 int c;23 while ((c child_in.read()) ! -1) {24 tempSb.append((char)c);25 }26 } catch (UnsupportedEncodingException e) {27 e.printStackTrace();28 } catch (IOException ex) {29 ex.printStackTrace();30 }31 32 return tempSb.toString();33 }34 }35 36 其中两个变量需要修改一下。a1“java_bin_path”jdk的bin目录a2“source_file”要转换的中文所在的文本文件。2.a.txt文本文件中文测试中文 3.输出结果\u4e2d\u6587\u6d4b\u8bd5\u4e2d\u6587转载于:https://www.cnblogs.com/pencilsoft/archive/2009/04/16/1436872.html