JSON解析富文本特殊符号导致报错 解决方法 base64


开源BASE64

https://github.com/dankogai/js-base64


npm install --save js-base64


In Browser

<script src="base64.js"></script>

node.js

var Base64 = require('js-base64').Base64;

es6+

import { Base64 } from 'js-base64';


Base64.encode('dankogai');  // ZGFua29nYWk=
Base64.encode('小飼弾');    // 5bCP6aO85by+
Base64.encodeURI('小飼弾'); // 5bCP6aO85by-
Base64.decode('ZGFua29nYWk=');  // dankogai
Base64.decode('5bCP6aO85by+');  // 小飼弾
Base64.decode('5bCP6aO85by-');  // 小飼弾