url-Encode vs Base64 encoding ( usages)?(url-Encode vs Base64 编码(用法)?)
问题描述
我在想……
(除了 base64 的加号+"在查询字符串中的问题 - 它被翻译为空格"并且可以通过 %2b 解决) :---> 这是首选如何在查询字符串中传输数据?
(except the issue with the base64's plus'+' sign in query string - which is translated to 'space' and can be solved by %2b) :---> which is the preferred way to transfer data in query string?
这两个功能都可以通过JS命令来使用:
Both functions can be used through the JS commands:
btoa
encodeUriComponent
所以我问自己(和你):
so im asking myself(and you) :
什么时候我应该使用 what ?(我一直使用 encodeUriCompoonent
- 本能).
when should I use what ? ( ive always used encodeUriCompoonent
- by instinct).
定义不同的问题 - 但实现可能相似......
the problem that the definitions are different - but the implementations can be similar...
我想我找到了问的原因......(以及为什么以前没有人问过)
I think ive found the reason for asking.... ( and why nobody asked it before)
推荐答案
base64用于传输二进制数据.(IE 不支持,无法编码空间字符.)
encodeURIComponent 只对特殊字符进行编码.
encodeURIComponent only encodes special characters.
有趣的是,如果没有 encodeURIComponent,您将无法将 base64 应用于 unicode 字符串:https://developer.mozilla.org/en/DOM/window.btoa
An interesting thing is that you can't apply base64 to unicode strings without encodeURIComponent: https://developer.mozilla.org/en/DOM/window.btoa
这篇关于url-Encode vs Base64 编码(用法)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:url-Encode vs Base64 编码(用法)?


- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01