为什么这些链接不同但效果相同?
Why these links are different and works same?
https://www.google.com/
https%3A%2F%2Fwww.google.com%2F
以上两个link有什么不同。以及如何使用 javascript 或正则表达式将 Ist link 转换为 2nd link。请高手帮忙指点一下。
decodeURIComponent('https%3A%2F%2Fwww.google.com%2F')
URL 编码将字符转换为可以在 Internet 上传输的格式。
URLs 只能使用 ASCII 字符集通过 Internet 发送。
由于 URL 经常包含 ASCII 集之外的字符,因此必须将 URL 转换为有效的 ASCII 格式。
URL 编码将不安全的 ASCII 字符替换为“%”后跟两个十六进制数字。
URLs 不能包含 spaces。 URL 编码通常用加号 (+) 或 %20 替换 space。
我可以帮助解决第一个问题:这两个链接之间没有区别。一种使用 UTF-8 codes instead of the symbols. You can verify this by converting the URL in a URL Encoder/Decoder 编码。
其他人将不得不使用 JS 或正则表达式帮助转换。
https://www.google.com/
https%3A%2F%2Fwww.google.com%2F
以上两个link有什么不同。以及如何使用 javascript 或正则表达式将 Ist link 转换为 2nd link。请高手帮忙指点一下。
decodeURIComponent('https%3A%2F%2Fwww.google.com%2F')
URL 编码将字符转换为可以在 Internet 上传输的格式。
URLs 只能使用 ASCII 字符集通过 Internet 发送。
由于 URL 经常包含 ASCII 集之外的字符,因此必须将 URL 转换为有效的 ASCII 格式。
URL 编码将不安全的 ASCII 字符替换为“%”后跟两个十六进制数字。 URLs 不能包含 spaces。 URL 编码通常用加号 (+) 或 %20 替换 space。
我可以帮助解决第一个问题:这两个链接之间没有区别。一种使用 UTF-8 codes instead of the symbols. You can verify this by converting the URL in a URL Encoder/Decoder 编码。 其他人将不得不使用 JS 或正则表达式帮助转换。