执行 encodeURIComponent(String.fromCharCode(0xDFFF))
报错:
Uncaught URIError: URI malformed
解决方法:去掉非法字符,或者 先 escape 一下
另外对于 decodeURIComponent('%9') 时报 Uncaught URIError: URI malformed 的容错方案:
可以考虑将报错部分的几个字符去掉,再解码。
要注意的点: 汉字编码后不止一个%XX,如 encodeURIComponent('啊') 输出:"%E5%95%8A"
在线地址:http://haiyang.me/other/decode.html