2个回答
展开全部
public static void main(String[] args) {
System.out.println(toUnicode("开源中国社区"));
}
public static String toUnicode(String s) {
String as[] = new String[s.length()];
String s1 = "";
for (int i = 0; i < s.length(); i++) {
as[i] = Integer.toHexString(s.charAt(i) & 0xffff);
s1 = s1 + "\\u" + as[i];
}
return s1;
}
System.out.println(toUnicode("开源中国社区"));
}
public static String toUnicode(String s) {
String as[] = new String[s.length()];
String s1 = "";
for (int i = 0; i < s.length(); i++) {
as[i] = Integer.toHexString(s.charAt(i) & 0xffff);
s1 = s1 + "\\u" + as[i];
}
return s1;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询