TextDecoder を使用してシフトJISコードを Unicode に変換して表示します。
表示されるものはブラウザにある変換表次第になります。
See the Pen シフトJIS文字表 by Ikiuo (@ikiuo) on CodePen.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>シフトJIS文字表</title>
<style>
body {
margin: auto;
width: 750px;
}
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: 4px;
}
th {
background-color: #eeeeee;
}
td {
text-align: center;
}
.undef {
background-color: #ffeeff;
}
</style>
</head>
<body>
<script>
window.onload = function() {
const td_unassigned = '<td class="undef"> </td>';
const decoder = new TextDecoder('sjis');
const buffer = new ArrayBuffer(2);
const view = new DataView(buffer);
const sjis = new Map();
const hcode = [];
for (let y = 0xa1; y <= 0xdc; ++y) {
const h = y ^ 0x20;
let has = false;
view.setUint8(0, h);
for (let l = 0x40; l <= 0xfc; ++l) {
if (l == 0x7f)
continue;
view.setUint8(1, l);
const us = decoder.decode(view);
if (us.length < 1)
continue;
if (us.charCodeAt(0) == 0xfffd)
continue;
sjis.set(view.getUint16(0, false), us);
has = true;
}
if (has)
hcode.push(h);
}
html = '<table border="1">';
html += '<tr><th colspan="17">シフトJIS文字表</th></tr>';
for (const h of hcode) {
const hh = h << 8;
html += '<tr><th> </th>';
for (let x = 0; x < 16; ++x)
html += `<th>${x.toString(16).toUpperCase()}</th>`;
html += '</tr>';
for (let lp = 0x40; lp <= 0xfc; lp += 16) {
const scode = hh + lp;
html += `<tr><th>${scode.toString(16).toUpperCase()}</th>`;
for (let x = 0; x < 16; ++x) {
const us = sjis.get(scode + x);
if (!us)
html += td_unassigned;
else
html += `<td>${us}</td>`;
}
html += '</tr>';
}
}
html += '</table>'
document.body.innerHTML = html;
}
</script>
</body>
</html>