1
2

More than 1 year has passed since last update.

EUC-JP 文字表 - 幅広版

Posted at

TextDecoder を使用して EUC-JP を Unicode に変換して表示します。

表示されるものはブラウザにある変換表次第になります。

行列は JIS X 0208 の区点と同じハズです。

See the Pen EUC-JP 文字表 by Ikiuo (@ikiuo) on CodePen.

<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>EUC-JP 文字表</title>
    <style>
     table {
         border: solid 0px;
         border-left: solid 1px lightgray;
         border-top: solid 1px lightgray;
         border-collaspe: collaspe;
         border-spacing: 0;
     }
     th, td {
         border: solid 0px;
         border-right: solid 1px lightgray;
         border-bottom: solid 1px lightgray;
         padding: 0.2em;
     }
     th {
         background-color: #eeeeee;
     }
     td {
         text-align: center;
     }
     .undef {
         background-color: #ffeeff;
     }
     .xxsmall {
         font-size: xx-small;
     }
    </style>
  </head>
  <body>
    <script>

     window.onload = function() {
         const td_unassigned = '<td class="undef"></td>';

         const decoder = new TextDecoder('euc-jp');
         const buffer = new ArrayBuffer(2);
         const view = new DataView(buffer);
         const euc_jp = new Map();

         for (let h = 0xa1; h <= 0xfe; ++h) {
             view.setUint8(0, h);
             for (let l = 0xa1; l <= 0xfe; ++l) {
                 view.setUint8(1, l);

                 const us = decoder.decode(view);
                 if (us.length < 1)
                     continue;
                 if (us.charCodeAt(0) == 0xfffd)
                     continue;
                 euc_jp.set(view.getUint16(0, false), us);
             }
         }

         html = '<table border="1">';
         html += '<tr><th colspan="96">EUC-JP 文字表</th></tr>';

         html += '<tr><th></th><th></th>';
         for (let l = 0xa1; l <= 0xfe; ++l)
             html += `<th class="xxsmall">${l-0xa0}</th>`;
         html += '</tr>';
         html += '<tr><th></th><th></th>';
         for (let l = 0xa1; l <= 0xfe; ++l)
             html += `<th class="xxsmall">${l.toString(16).toUpperCase()}</th>`;
         html += '</tr>';

         for (let h = 0xa1; h <= 0xfe; ++h) {
             const hh = h << 8;
             html += '<tr>';
             html += `<th class="xxsmall">${h-0xa0}</th>`;
             html += `<th class="xxsmall">${h.toString(16).toUpperCase()}</th>`;
             for (let l = 0xa1; l <= 0xfe; ++l) {
                 const us = euc_jp.get(hh + l);
                 if (!us)
                     html += td_unassigned;
                 else
                     html += `<td class="xxsmall">${us}</td>`;
             }
             html += '</tr>';
         }
         html += '</table>'

         document.body.innerHTML = html;
     }

    </script>
  </body>
</html>
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2