zoukankan      html  css  js  c++  java
  • escape和unescape知识点

    decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码。

    encodeURI() 函数可把字符串作为 URI 进行编码

    <script>
    
    var uri="my test.asp?name=ståle&car=saab";
    document.write(encodeURI(uri)+ "<br>");
    document.write(decodeURI(uri));
    
    </script>

    运行结果:

    my%20test.php?name=st%C3%A5le&car=saab
    my test.asp?name=ståle&car=saab

    escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。

    该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: * @ - _ + . / 。其他所有的字符都会被转义序列替换

    unescape() 函数可对通过 escape() 编码的字符串进行解码

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    var str="Need tips? Visit RUNOOB!";
    var str_esc=escape(str);
    document.write(str_esc + "<br>")
    document.write(unescape(str_esc))
    </script>
    
    </body>
    </html>

    运行结果:

    Need%20tips%3F%20Visit%20RUNOOB%21
    Need tips? Visit RUNOOB!
  • 相关阅读:
    【Gym
    [matlab工具箱] 曲线拟合Curve Fitting
    数学建模 常用
    “这么多人给我作证,我不怕”
    超星尔雅刷课辅助
    细思《都挺好》
    P5173 传球
    [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones
    CF 1131C Birthday
    CF 634A Island Puzzle
  • 原文地址:https://www.cnblogs.com/dazhi151/p/12332239.html
Copyright © 2011-2022 走看看