示例代码

<!DOCTYPE html>
<html lang="zh">

    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>JavaScript字符串编解码</title>
    </head>

    <body>
        <script>
            var str = 'a';
            //字符的 Unicode 编码
            var unicode = str.charCodeAt(0);
            console.log(unicode);
            //字符解码
            var strNew = String.fromCharCode(unicode);
            console.log(strNew);
        </script>
    </body>

</html>

 

相关文章:

  • 2022-02-16
  • 2021-07-01
  • 2022-12-23
  • 2021-06-23
  • 2021-12-19
  • 2021-11-21
  • 2021-09-27
  • 2021-04-03
猜你喜欢
  • 2021-09-12
  • 2022-01-02
  • 2021-09-19
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案