Skip to content

[js] 第80天 举例说明什么是decodeURI()和encodeURI()是什么? #574

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第80天 举例说明什么是decodeURI()和encodeURI()是什么?

Activity

ghost

ghost commented on Jul 5, 2019

@ghost
  • encodeURI():将 URI 中的每个字符编码为 1-4 个格式为 %xx 的转义序列(xx 为十六进制数),但不包括 ASCII 数字、字母、URL 分隔符(/?,&、...)、以及其他部分 ASCII 字符。具体见 MDN
    • Example: encodeURI('http://example.com/端点?键=值') => 'http://example.com/%E7%AB%AF%E7%82%B9?%E9%94%AE=%E5%80%BC'
  • decodeURI():将已经编码的 URI 中的转义序列解码为它们表示的字符,但除了 encodeURI() 不会编码的字符。
  • encodeURIComponent():用于编码 URI 中的组成部分。它除了转义 encodeURI() 指定的字符,还会转义 URL 分隔符(/?,&、...)
    • Example: encodeURIComponent('测试/测试?测试=测试') => '%E6%B5%8B%E8%AF%95%2F%E6%B5%8B%E8%AF%95%3F%E6%B5%8B%E8%AF%95%3D%E6%B5%8B%E8%AF%95'
  • decodeURIComponent():将已经编码的 URI 组成部分中的转义序列解码为它们表示的字符,但除了 encodeURIComponent() 不会编码的字符。
dondonZh

dondonZh commented on Jul 5, 2019

@dondonZh

encodeUri编码
decodeURI 解码

WangYang-Rex

WangYang-Rex commented on Jul 5, 2019

@WangYang-Rex

日常主要用于对字符串编码及解码

zhoushaw

zhoushaw commented on Jul 8, 2019

@zhoushaw

787416-20160315130559912-1326279345

smile-2008

smile-2008 commented on Feb 3, 2021

@smile-2008

encodeUri编码
decodeURI 解码

xiaoqiangz

xiaoqiangz commented on Jun 21, 2022

@xiaoqiangz

encodeUrl: 编码
decodeUrl: 解码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @smile-2008@haizhilin2013@WangYang-Rex@xiaoqiangz@dondonZh

        Issue actions

          [js] 第80天 举例说明什么是decodeURI()和encodeURI()是什么? · Issue #574 · haizlin/fe-interview