为什么要进行URL编码,先码住别人的:
https://www.cnblogs.com/jerrysion/p/5522673.html
然后,
public class URLTest { public static void main(String[] args) throws UnsupportedEncodingException{ String name = "张三"; /* * 比特 * -27,-68,-96,-28,-72,-119 * URL * %E5%BC%A0%E4%B8%89 */ byte[] bytes = name.getBytes(); for (byte x : bytes){ System.out.print(x + ","); } System.out.println(); String s = URLEncoder.encode(name, "UTF-8"); System.out.println(s); } }
结果是:
-27,-68,-96,-28,-72,-119,
%E5%BC%A0%E4%B8%89
-27就等于E5,因为-27是用补码存储的
1110 0101