Skip to content

Instantly share code, notes, and snippets.

@nst
Last active August 29, 2015 14:04
Show Gist options
  • Save nst/6fe9652c3a7ef25d8106 to your computer and use it in GitHub Desktop.
Save nst/6fe9652c3a7ef25d8106 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
HIGH_BITS_MAX = 0xFF
LOW_BITS_MAX = 0xFF
def write_plane(plane_number, path):
with open(path, 'w+') as f:
f.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Plane %02x</title>
</head>
<style>
table, th, td {
border: 1px solid black;
border-collapse:collapse;
}
th {
font-family:Monospace;
}
</style>
<body>
""" % plane_number)
f.write("<table>\n")
f.write("<tr>\n")
f.write(" <th>%02x</td>\n" % plane_number)
for low_bits in range(LOW_BITS_MAX+1):
f.write(" <th>%02x</td>\n" % low_bits)
f.write("</tr>\n")
for high_bits in range(HIGH_BITS_MAX+1):
f.write("<tr>\n")
f.write("<th>%02x</th>\n" % high_bits)
for low_bits in range(LOW_BITS_MAX+1):
i = (plane_number << 16) + (high_bits << 8) + low_bits
#s = "\\U%08x\\U0000FE0F" % i
s1 = "\\U%08x" % i
s2 = "\\U0000FE0F"
c1 = s1.decode('unicode-escape')
c2 = s2.decode('unicode-escape')
f.write(" <td>%s%s</td>\n" % (c1.encode('utf-8'), c2.encode('utf-8')))
f.write("</tr>\n")
f.write("</table>\n")
f.write("""
</body>
</html>\n""")
for plane_number in range(2):
path = "/tmp/plane_%02x_fe0f.html" % plane_number
#path = "/tmp/plane_%02x.html" % plane_number
print path
write_plane(plane_number, path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment