1 |
#!/usr/bin/perl |
#!/usr/bin/perl -w |
2 |
# unicode-blocks -- Script to generate java.lang.Character.UnicodeBlock |
# unicode-blocks.pl -- Script to generate java.lang.Character.UnicodeBlock |
3 |
# Copyright (C) 2002 Free Software Foundation, Inc. |
# Copyright (C) 2002 Free Software Foundation, Inc. |
4 |
# |
# |
5 |
# This file is part of GNU Classpath. |
# This file is part of GNU Classpath. |
45 |
# will have to tweak this some for future use. |
# will have to tweak this some for future use. |
46 |
# |
# |
47 |
# author Eric Blake <ebb9@email.byu.edu> |
# author Eric Blake <ebb9@email.byu.edu> |
48 |
|
# |
49 |
|
# usage: unicode-blocks.pl <blocks.txt> |
50 |
|
# where <blocks.txt> is obtained from www.unicode.org (named Blocks-3.txt |
51 |
|
# for Unicode version 3.0.0). |
52 |
|
|
|
# usage: unicode-blocks.pl Blocks-3.txt |
|
53 |
|
|
54 |
|
die "Usage: $0 <blocks.txt>" unless @ARGV == 1; |
55 |
open (BLOCKS, $ARGV[0]) || die "Can't open Unicode block file: $!\n"; |
open (BLOCKS, $ARGV[0]) || die "Can't open Unicode block file: $!\n"; |
56 |
|
|
57 |
# A hash of added fields and the JDK they were added in, to automatically |
# A hash of added fields and the JDK they were added in, to automatically |
82 |
* A family of character subsets in the Unicode specification. A character |
* A family of character subsets in the Unicode specification. A character |
83 |
* is in at most one of these blocks. |
* is in at most one of these blocks. |
84 |
* |
* |
85 |
* This class was generated by doc/unicode/unicode-blocks.pl. |
* This inner class was generated by doc/unicode/unicode-blocks.pl. |
86 |
* |
* |
87 |
|
* @author doc/unicode/unicode-blocks.pl (written by Eric Blake) |
88 |
* @since 1.2 |
* @since 1.2 |
89 |
*/ |
*/ |
90 |
public static final class UnicodeBlock extends Subset |
public static final class UnicodeBlock extends Subset |
144 |
while (<BLOCKS>) { |
while (<BLOCKS>) { |
145 |
next if /^\#/; |
next if /^\#/; |
146 |
($start, $end, $block) = split(/; /); |
($start, $end, $block) = split(/; /); |
147 |
|
next unless defined $block; |
148 |
chomp $block; |
chomp $block; |
149 |
$block =~ s/ *$//; |
$block =~ s/ *$//; |
|
next if $block eq ""; |
|
150 |
if (! $seenSpecials and $block =~ /Specials/) { |
if (! $seenSpecials and $block =~ /Specials/) { |
151 |
# Special case SPECIALS, since it is two disjoint ranges |
# Special case SPECIALS, since it is two disjoint ranges |
152 |
$seenSpecials = 1; |
$seenSpecials = 1; |
167 |
} |
} |
168 |
} |
} |
169 |
# Special case the name of PRIVATE_USE_AREA. |
# Special case the name of PRIVATE_USE_AREA. |
170 |
$block =~ s/(Private Use)/\1 Area/; |
$block =~ s/(Private Use)/$1 Area/; |
171 |
|
|
172 |
($name = $block) =~ tr/a-z -/A-Z__/; |
($name = $block) =~ tr/a-z -/A-Z__/; |
173 |
push @names, $name; |
push @names, $name; |