☀【组件】转换16进制
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> // 将文字转换为16进制 function textToSix(str) { return escape(str).replace(/%/g, '\\').toLowerCase() } // 将16进制转换为文字 function sixToText(str) { return unescape(str) } console.log(escape('中')) console.log(escape('中').replace(/%/g, '\\')) console.log(escape('中').replace(/%/g, '\\').toLowerCase()) console.log(sixToText('\u4e2d\u56fd')) console.log(textToSix('中国')) </script> </body> </html>
浙公网安备 33010602011771号