summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/tool/blocks2defcharrange.rb
blob: 186d0ba94d7f82cf196ffbdab138b1ffd00c1c57 (plain)
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
#! /usr/bin/ruby

# The following script converts Blocks.txt
# (http://unicode.org/Public/UNIDATA/Blocks.txt)
# to the character range definitions of LuaTeX-ja.

# USAGE: ruby blocks2defcharrange.rb > unicodeBlocks.tex

count = 1
open("Blocks.txt", "r").each_line {|line|
  if line =~ /#/
    line = $`
  end
  if line =~ /^\s*$/
    next
  end
  if line =~ /([0-9a-f]+)\.\.([0-9a-f]+); (.*)/i
    bcharcode = $1
    echarcode = $2
    blockname = $3
    print "\\defcharrange{", count
    print "}{\"", bcharcode, "-\"", echarcode, "} % ", blockname, "\n"
    count += 1
  end
}