base 64 转码解码 表情包emoji转码
轉(zhuǎn)碼方式?
bota和?atob??
從base64到atob和btoa的一些理解
https://segmentfault.com/a/1190000016379916
附上菜鳥教程鏈接
bota?https://www.runoob.com/jsref/met-win-btoa.html
atob?https://www.runoob.com/jsref/met-win-atob.html
演示鏈接?https://www.runoob.com/try/try.php?filename=tryjsref_win_atob
encodeURI() 、decodeURI()、? decodeURIComponent()、encodeURIComponent()?
附上菜鳥教程鏈接
encodeURI()??https://www.runoob.com/jsref/jsref-encodeuri.html
decodeURI()??https://www.runoob.com/jsref/jsref-decodeuri.html
decodeURIComponent()?https://www.runoob.com/jsref/jsref-decodeuricomponent.html
encodeURIComponent()? ?https://www.runoob.com/jsref/jsref-encodeuricomponent.html
附上參考鏈接
?https://www.cnblogs.com/mu-zi-/p/8856907.html
https://blog.csdn.net/li2327234939/article/details/53675211
?
代碼都是vue 寫法,注意修改部分內(nèi)容?
?這個(gè)轉(zhuǎn)碼表情包會(huì)報(bào)錯(cuò),但是轉(zhuǎn)碼成功顯示沒問題
附原文鏈接? 未找到
附上報(bào)錯(cuò)參考鏈接
https://cloud.tencent.com/developer/section/1191688
https://blog.csdn.net/u010486124/article/details/81102224
b64EncodeUnicode(str) {return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {return String.fromCharCode('0x' + p1);}))},b64DecodeUnicode(str) {return decodeURIComponent(atob(str).split('').map(function(c) {return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);}).join(''));},?
下面這個(gè)轉(zhuǎn)碼沒有報(bào)錯(cuò) 附上原文鏈接
?https://blog.csdn.net/qq_35393472/article/details/103536104?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param
encode (input) { var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = this._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4); } return output; },_utf8_encode (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; },decode (input) { var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = _keyStr.indexOf(input.charAt(i++)); enc2 = _keyStr.indexOf(input.charAt(i++)); enc3 = _keyStr.indexOf(input.charAt(i++)); enc4 = _keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = this._utf8_decode(output); return output; },_utf8_decode (utftext) { var string = ""; var i = 0; var c = c1, c1 = c2, c2 = 0, c3;while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; },?或者使用插件試試 附上參考鏈接 本人未使用過
https://www.cnblogs.com/liangpi/p/11821975.html
總結(jié)
以上是生活随笔為你收集整理的base 64 转码解码 表情包emoji转码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颜色的前世今生20·三原色到底该用哪一个
- 下一篇: Armijo-Goldstein准则与W