V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
EchoFUN
V2EX  ›  程序员

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

  •  
  •   EchoFUN · Jun 25, 2012 · 3570 views
    This topic created in 5059 days ago, the information mentioned may be changed or developed.
    一直没搞明。比如说“你好”,用escape就是“%u4F60%u597D”,用encodeURI就是“%E4%BD%A0%E5%A5%BD”。
    具体在应用中有啥例子么,谢谢了。
    2 replies    1970-01-01 08:00:00 +08:00
    darasion
        1
    darasion  
       Jun 25, 2012
    javascript 的 url 编码一律使用 encodeURIComponent ,url 解码一律用 decodeURIComponent ,其他的都不好使,别费劲区分了。


    例如:

    query = '?a='+encodeURIComponent ('被编码的字符') + '&b=' + encodeURIComponent('★☆◆*㊣');
    imcotton
        2
    imcotton  
       Jun 25, 2012
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2331 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 01:37 · PVG 09:37 · LAX 18:37 · JFK 21:37
    ♥ Do have faith in what you're doing.