HTML5 Base64_encoding_and_decoding
2024-10-11 07:12:12
https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
In JavaScript there are two functions respectively for decoding and encoding base64 strings:
工作场景,客户端HTML片段的保存与再现。
The "Unicode Problem"
Since DOMString
s are 16-bit-encoded strings, in most browsers calling window.btoa
on a Unicode string will cause a Character Out Of Range
exception if a character exceeds the range of a 8-bit byte (0x00~0xFF). There are two possible methods to solve this problem:
- the first one is to escape the whole string (with UTF-8, see
encodeURIComponent
) and then encode it; - the second one is to convert the UTF-16
DOMString
to an UTF-8 array of characters and then encode it.
Here are the two possible methods.
其它相关帖子:
https://blog.coding.net/blog/resolve-atob-decode-chinese-character-outputting-messy-code-problem-in-javascript
http://levy.work/2017-03-24-black-magic-js-atob-with-utf8/
最新文章
- 如何学习Oracle
- 【转】Python资源 转自 dylanninin.com
- 用javascript协助导入图片
- U8记账凭证修改方法汇总
- android 14 进度条和拖动条
- 爬虫day 04(通过登录去爬虫 解决django的csrf_token)
- Asp.Net Web API(一)
- Android 常用的ORM框架详解
- Android实训案例(一)——计算器的运算逻辑
- 显示开机信息-dmesg
- [转] OpenStack — nova image-create, under the hood
- 136.137.260. Single Number &;&; 位运算
- 官方解析Cookies和Session的区别
- 使用requests库提交multipart/form-data 格式的请求
- JS结合a标签的使用
- 【转载】linux下升级npm以及node
- css基础示例代码
- AsyncTask、HandlerThread、IntentService和线程池
- 铁乐学Python_day03-字符串常用操作方法
- 主机名/etc/hosts文件的作用
热门文章
- Centos7下安装docker(1)
- Spark机器学习中ml和mllib中矩阵、向量
- 剑指offer.在O(1)时间内删除链表节点
- PAT A1104 Sum of Number Segments (20 分)——数学规律,long long
- 关于for,while,dowhile效率测试
- oracle 把查询结果插入到表中几种方式
- 随机指定范围内N个不重复的数
- 在IIS上部署你的ASP.NET Core项目 (转载)
- 【LeetCode232】 Implement Queue using Stacks★
- Python学习总结 05 pandas