Appendix talk:Korean Hanja by KPS 9566 hangyol code
Jump to navigation
Jump to search
Source code used to generate this
[edit]#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
a = 45
by_kuten = {}
f = open("KPS9566.TXT", "r") # ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/KPS9566.TXT
b = f.read()
b2 = b.split("\n")
b2 = [i.split("#")[0].strip() for i in b2]
b2 = [i for i in b2 if i]
b2 = [i.split() for i in b2]
b2 = [i for i in b2 if i[1:]]
for i, j in b2:
i = i.split("x", 1)[1]
j = j.split("x", 1)[1]
i = int(i, 16)
j = int(j, 16)
j = chr(j)
if i < 0xA1A1:
continue
ku = (i >> 8) - 0xA0
ten = (i & 0xFF) - 0xA0
if ten < 1:
continue
by_kuten[(ku, ten)] = j
print("""__NOTOC__
{|""")
for i in range(a, 95):
if (i - a) and not ((i - a) % 5):
print("|-")
print("|")
print("===Row %d===" % i)
for j in range(1, 95):
if (i, j) in by_kuten:
print("[[", by_kuten[(i, j)], sep = "", end = "]] ")
else:
break
print()
print("|}")