Skip to content

Commit

Permalink
add some tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ButTaiwan committed Oct 21, 2021
1 parent 36f5697 commit 5c31167
Show file tree
Hide file tree
Showing 16 changed files with 56,552 additions and 0 deletions.
5,402 changes: 5,402 additions & 0 deletions js/big5-1.txt

Large diffs are not rendered by default.

7,672 changes: 7,672 additions & 0 deletions js/big5-2.txt

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions js/charsets.txt

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions js/charsets2.txt

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions js/compress.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
fx = File.open('charsets.txt', 'w:utf-8')

Dir.glob('*.txt').each { |fn|
next if fn =~ /charsets/

f = File.open(fn, 'r:utf-8')
cjk = '0' * 21000
ext = []
f.each { |s|
s.chomp!
next if s == ''
next if s[0] == '#'

c, u, x = s.split(/\t/)
d = u.to_i(16)
if (0x4E00..0x9FFF).include?(d)
cjk[d - 0x4E00] = '1'
else
ext << "0x#{u}"
end
}
f.close

cx = []
700.times { |i|
cx << '0x' + cjk[i*30 ... (i+1)*30].reverse.to_i(2).to_s(16).upcase
}

fk = fn.gsub(/\.txt/, '')

fx.puts "\t'#{fk}': {"
fx.puts "\t\tmap: [" + cx.join(',') + '],'
fx.puts "\t\text: [" + ext.join(',') + '] },'
}
fx.close
46 changes: 46 additions & 0 deletions js/compress2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
fx = File.open('charsets2.txt', 'w:utf-8')

max = 20994
zp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
fmap = {'big5-1' => 'Big5-1', 'big5-2' => 'Big5-2', 'edu_standard_1' => 'TEdu-1', 'edu_standard_2' => 'TEdu-2', 'han_taiyu_keyu2' => 'TTaiKe',
'j_jinmei' => 'JJinmei', 'j_joyo' => 'JJoyo', 'sjis-1' => 'JIS-1', 'sjis-2' => 'JIS-2'}

Dir.glob('*.txt').each { |fn|
next if fn =~ /charsets/

f = File.open(fn, 'r:utf-8')
cjk = '0' * max #21000
ext = []
cnt = 0
f.each { |s|
s.chomp!
next if s == ''
next if s[0] == '#'

c, u, x = s.split(/\t/)
d = u.to_i(16)
cnt += 1
if (0x4E00..0x9FFF).include?(d)
cjk[d - 0x4E00] = '1'
else
ext << u # += sprintf('%05x', d).upcase
end
}
f.close

cx = ''
(max/6).times.each { |i|
cx += zp[cjk[i*6 ... (i+1)*6].reverse.to_i(2)]
}

fk = fn.gsub(/\.txt/, '')
cs = fmap[fk]

fx.puts "\t'#{cs}': { 'cnt': #{cnt},"
fx.puts "\t\t'map': '#{cx}',"
fx.puts "\t\t'ext': '#{ext.join(' ')}'},"

# fx.puts "\t\tmap: [" + cx.join(',') + '],'
# fx.puts "\t\text: [" + ext.join(',') + '] },'
}
fx.close
Loading

0 comments on commit 5c31167

Please sign in to comment.