当前位置:网站首页>编码解码(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: ~!*()'
边栏推荐
猜你喜欢

How to get page data

Redis middleware (from building to refuse pit)

灵魂发问:MySQL是如何解决幻读的?

阿里腾讯面试一二

Parsing MySQL Databases: "SQL Optimization" vs. "Index Optimization"

sqlserver怎么查询一张表中同人员的交叉日期

Shell: Conditional test action

leetcode-6134: Find the closest node to the given two nodes

YOLOv7-Pose尝鲜,基于YOLOv7的关键点模型测评

报告:想学AI的学生数量已涨200%,老师都不够用了
随机推荐
18张图,直观理解神经网络、流形和拓扑
Graduation thesis writing skills
experiment....
50.【动态二维数组的运用】
Yang Hui Triangle (C language implementation)
企业微信群:机器人定时提醒功能数据库配置化
淘宝商品详情又见淘宝详情,升级高级版 API
堆内存的介绍及应用(含例子)
实验。。。。
How does UXDB return the number of records for all tables in the current database?
周鸿祎称微软抄袭 360 安全模式后发文否认;英特尔CEO基辛格回应市值被AMD超越:股价下跌是咎由自取|极客头条
指针的介绍及应用
Introduction and application of pointers
Comprehensive experiment BGP
node 格式化时间的传统做法与高级做法(moment)
安装GBase 8c数据库的时候,报错显示“Resource,如何解决?
Ogg synchronizes oracle to mysql, there may be characters that need to be escaped in the field, how to configure escape?
notes....
Mysql database deployment and initialization steps
ogg同步oracle到mysql,字段里面可能有需要转义的字符,怎么配置转义?