package demo0809.demo1; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Test333 { public static void main(String[] args) throws UnsupportedEncodingException { String str = URLEncoder.encode("中国", "UTF-8"); String[] s = str.substring(1).split("%"); StringBuffer s8 = new StringBuffer(); for(int i=0;i<s.length;i++){ s8.append("\\"+Integer.toOctalString(Integer.valueOf(s[i],16))); } System.out.println(s8.toString()); } }
时间: 2024-10-19 06:23:57