-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkct-uni-2.lua
executable file
·104 lines (92 loc) · 3.28 KB
/
kct-uni-2.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env texlua
local src = {}
src[0] = io.open(arg[1],'r')
src[1] = io.open(arg[2],'r')
src[2] = io.open(arg[3],'r')
src[3] = io.open(arg[4],'r')
src[4] = io.open(arg[5],'r')
src[5] = io.open(arg[6],'r')
local texout = io.open(arg[7],'w')
tprint = function (a) texout:write(a .. '\n') end
local txtout = io.open(arg[8],'w')
dprint = function (a) txtout:write(a .. '\n') end
tprint('\\documentclass[uplatex]{jsarticle}')
tprint('\\usepackage[dvipdfmx]{graphicx,xcolor}')
tprint('\\definecolor{green}{rgb}{0,0.5,0}\n')
tprint('\\usepackage[width=44zw,lines=45]{geometry}')
tprint('\\usepackage{supertabular,booktabs,metalogo,lmodern}')
tprint('\\begin{document}\\fboxsep0pt{\\centering')
tprint('\\tablehead{%')
tprint('\\toprule')
tprint('&UCS&JIS&\\pTeX&u\\pTeX&\\XeTeX&Lua\\TeX&Lua\\TeX-ja&\\\\')
tprint('\\midrule')
tprint('}%')
tprint('\\tabletail{\\bottomrule}')
tprint('\\begin{supertabular}{ccccccccp{5em}}')
dprint('## kct-uni-out.txt: \\[k]catcode table of JIS X 0213 non-Kanji characters.')
dprint('## This is generated by kct-uni.sh.')
dprint('##')
dprint("## JIS04 characters which can't be represent by one UCS character")
dprint("## are omitted from this table.")
dprint('##')
dprint('## UCS\tJIS\t区\t点\tpTeX\tupTeX\tXeTeX\tLuaTeX\tLuaTeX-ja\tNote')
local cxt = function(n)
return '\\textcolor{' ..
(((n==16 or n==17 or n==11) and 'green')
or ((n==15) and 'blue' or 'red'))
.. '}{' .. tostring(n) .. '}'
end
local cyt = function(n, x)
return cxt(n) .. ' (\\textcolor{'
.. (x=='0' and 'black}{\\tt\\bfseries JA}' or 'blue}{\\tt AL}' )
.. ')'
end
local czt = function(n, x)
return (x=='N' and ('(' .. cxt(n) .. ')') or cxt(n) )
end
local cxd = function(n)
return tostring(n) .. '\t'
end
local cyd = function(n, x)
return cxd(n) .. (x==0 and 'J\t' or 'A\t' )
end
local czd = function(n, x)
return (x=='N' and '-' or tostring(n) ) .. '\t'
end
local moji = function(c)
return '\\fcolorbox{cyan}{white}{\\Large\\kchar"'.. c .. '}'
end
local z = {}
local zu, zx, zlc, zlj
for il in src[0]:lines() do
zu = src[1]:read('*n')
zx = src[2]:read('*n')
zl = src[3]:read('*n')
zp = src[5]:read('*n')
zlc, zlj = (src[4]:read('*l')):match('(%w*)-(%w*)')
zlc = tonumber(zlc)
local za, zb, zc, zd = il:match('(%w*) (%w*) (.)(.)')
-- if (zlc==11 and zu==18)or(zlc==12 and zu~=18) then
tprint(
moji(zb) .. '&\\tt U+' .. zb .. '&\\tt 0x' .. za .. '&'
.. czt(zp, zd) .. '&' .. cxt(zu).. '&' .. cxt(zx) .. '&'
.. cxt(zl) .. '&' .. cyt(zlc, zlj)
.. (zc=='F' and '&Fullwidth' or (zc=='W' and '&Windows' or ''))
.. '\\\\')
dprint('U+' .. zb .. '\t0x' .. za .. '\t'
.. (tonumber(za,16)//256-32) .. '\t'
.. (tonumber(za,16)%256-32) .. '\t'
.. czd(zp,zd)
.. cxd(zu).. cxd(zx).. cxd(zl) .. cyd(zlc, zlj)
.. (zd=='N' and '[JIS04] ' or '')
.. (zc=='F' and 'Fullwidth' or (zc=='W' and 'Windows' or ''))
)
-- end
end
for k=0,5 do z[k]=src[k]:close() end
tprint('\\end{supertabular}\\par}\\medskip')
tprint('\\pTeX の列の括弧囲みは,その文字がJIS~X~0208:1990に規定されていないことを示す.\\\\')
tprint('Unicodeで合成文字で表さないと表せない文字は省略した.')
tprint('\\end{document}')
texout:close()
txtout:close()