3 # Generate UTF-8 case mapping tables
5 # (c) 2010 Steve Bennett <steveb@workware.net.au>
7 # See LICENCE for licence details.
10 # Parse the unicode data from: http://unicode.org/Public/UNIDATA/UnicodeData.txt
11 # to generate case mapping tables
13 set f
[open [lindex $argv 0]]
15 puts "static const struct casemap unicode_case_mapping\[\] = \{"
16 while {[gets $f buf
] >= 0} {
17 foreach {code name class x x x x x x x x x upper
lower} [split $buf ";"] break
25 if {$class ne
"Lu" && $class ne
"Ll"} {
38 if {$upper == $code && $lower == $code} {
41 set l
[expr {$lower - $code}]
42 set u
[expr {$upper - $code}]
43 if {abs
($u) > 127 || abs
($l) > 127} {
44 # Can't encode both in one byte, so use indirection
45 lappend jumptable
$code $lower $upper
50 error "Too many entries in the offset table!"
53 set entry [string tolower
"$code, $l, $u"]
60 puts "static const struct caseextmap unicode_extmap\[\] = \{"
61 foreach {c l u
} $jumptable {