码迷,mamicode.com
首页 > Web开发 > 详细

为什么要进行URL编码

时间:2018-05-02 22:15:04      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:support   target   结果   别人   sys   nbsp   targe   []   htm   

为什么要进行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

 

为什么要进行URL编码

标签:support   target   结果   别人   sys   nbsp   targe   []   htm   

原文地址:https://www.cnblogs.com/haoabcd2010/p/8982575.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!