V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
EchoFUN
V2EX  ›  程序员

encodeURI, escape 这两个函数有啥区别啊?

  •  
  •   EchoFUN · 2012-06-25 18:20:53 +08:00 · 3008 次点击
    这是一个创建于 4320 天前的主题,其中的信息可能已经有所发展或是发生改变。
    一直没搞明。比如说“你好”,用escape就是“%u4F60%u597D”,用encodeURI就是“%E4%BD%A0%E5%A5%BD”。
    具体在应用中有啥例子么,谢谢了。
    2 条回复    1970-01-01 08:00:00 +08:00
    darasion
        1
    darasion  
       2012-06-25 18:41:42 +08:00
    javascript 的 url 编码一律使用 encodeURIComponent ,url 解码一律用 decodeURIComponent ,其他的都不好使,别费劲区分了。


    例如:

    query = '?a='+encodeURIComponent ('被编码的字符') + '&b=' + encodeURIComponent('★☆◆*㊣');
    imcotton
        2
    imcotton  
       2012-06-25 18:41:59 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5392 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:51 · PVG 13:51 · LAX 22:51 · JFK 01:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.