aboutsummaryrefslogtreecommitdiff
path: root/libjava/scripts/blocks.pl
blob: 400967145a6065e3780936edeeee9482e94361a4 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/perl

if ($ARGV[0] eq '')
{
    $file = 'Blocks.txt';
    if (! -f $file)
    {
	# Too painful to figure out how to get Perl to do it.
	# FIXME.
	system 'wget -o .wget-log http://www.isi.edu/in-notes/iana/unidata/Blocks.txt';
    }
}
else
{
    $file = $ARGV[0];
}

open (INPUT, "< $file") || die "couldn't open $file: $!";

@array = ();
while (<INPUT>)
{
    next if /^#/;
    chop;

    ($start, $to, $text) = split (/; /);
    ($symbol = $text) =~ tr/a-z/A-Z/;
    $symbol =~ s/[- ]/_/g;

    # Special case for one of the SPECIALS.
    next if $start eq 'FEFF';

    printf "    public static final UnicodeBlock %s = new UnicodeBlock (\"%s\", '\\u%s', '\\u%s');\n",
           $symbol, $text, $start, $to;

    push (@array, $symbol);
}

printf "    private static final UnicodeBlock[] blocks = {\n";
foreach (@array)
{
    printf "      %s", $_;
    printf "," unless $_ eq 'SPECIALS';
    printf "\n";
}
printf "    };\n";

close (INPUT);