当前位置:网站首页>编码解码(btoa、encodeURIComponent、encodeURI、escape)
编码解码(btoa、encodeURIComponent、encodeURI、escape)
2022-08-01 09:39:00 【YF-SOD】
window.btoa(str)
用于编码形成 base-64 编码的字符串。
window.atob(str)
用于解码使用 base-64 编码的字符串(base64图片下载时候通常需要先解码,然后将解码内容转化为二进制数据下载)。
window.encodeURIComponent(str)
用于url的组成部分编码,不能用于整个url编码。把字符串作为 URI 组件进行编码。该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) 。其他字符(比如 :;/?:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序列替换的。假定任何保留字符都代表普通文本,所以必须编码它们。
window.decodeURIComponent(str)
对 encodeURIComponent() 函数编码的 URI 进行解码。
window.encodeURI(str)
专门用于uri编码中文处理,对以下在 URI 中具有特殊含义的 ASCII 标点符号,encodeURI() 函数是不会进行转义的: , / ? : @ & = + $ # (可以使用encodeURIComponent() 方法分别对特殊含义的 ASCII 标点符号进行编码)。假定URI 中的任何保留字符都有特殊意义,所有不会编码它们。
window.decodeURI(str)
对 encodeURI() 函数编码过的 URI 进行解码。
window.escape(str)
返回一个可在所有计算机上读取的编码 String 对象(使字符串具有可移植性,这样它就可以通过任何网络传输到任何支持 ASCII 字符的计算机)。不能用来对“统一资源标识符”(URI) 进行编码。对以下字符不会进行编码: * @ - _ + . /。
window.unescape(str)
对 unescape()函数编码过的 字符串进行解码。
区别
escape() will not encode: @*/+
encodeURI() will not encode: [email protected]#$&*()=:/,;?+'
encodeURIComponent() will not encode: ~!*()'
边栏推荐
- ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
- Yang Hui Triangle (C language implementation)
- Microsoft Azure & NVIDIA IoT developers season I | Azure IoT & NVIDIA Jetson development foundation
- C语言程序设计50例(三)(经典收藏)
- GBase 8s 锁分类
- Go-Excelize API source code reading (8) - GroupSheets(sheets []string), UngroupSheets()
- 企业微信群:机器人定时提醒功能数据库配置化
- Dataset之mpg:mpg数据集的简介、下载、使用方法之详细攻略
- Classify GBase 8 s lock
- various network protocols
猜你喜欢

阿里腾讯面试一二

Prime Ring Problem

《时代》杂志:元宇宙时代将改变世界

What's up with VS "Cannot find or open PDB file"?How to solve

leetcode-6134: Find the closest node to the given two nodes
Get the Token from the revised version of Qubutu Bed

Leetcode - 6135: the longest part of the figure

【软件架构模式】MVVM模式和MVC模式区别

基于MySql,Redis,Mq,ES的高可用方案解析

使用ESP32驱动QMA7981读取三轴加速度(带例程)
随机推荐
In the background of the GBase 8c database, what command is used to perform the master-slave switchover operation for the gtm and dn nodes
Redis中间件(从搭建到弃坑)
GBase 8s 锁分类
net stop/start mysql80 access denied
用OpenCV的边缘检测
【Untitled】
ClickHouse多种安装方式
sqlserver怎么查询一张表中同人员的交叉日期
AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
淘宝商品详情又见淘宝详情,升级高级版 API
获取页面数据的方法
Redis learning
PHP获取时间戳后写数据库的一个问题
How to implement deep copy in js?
Shell:条件测试操作
解析MySQL数据库:“SQL优化”与“索引优化”
How to ensure the consistency of database and cache data?
Go-Excelize API源码阅读(八)——GroupSheets(sheets []string)、UngroupSheets()
消息队列面试题(2022最新整理)
notes....