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:
btoaencodeUriComponent
所以我问自己(和你):
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# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
