-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepUnicodeBlock.sh
executable file
·73 lines (57 loc) · 1.58 KB
/
prepUnicodeBlock.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
echo "
package org.chartacaeli;
import java.util.HashMap;
import java.util.Map;
public final class UnicodeBlock {
public String name ;
public String nice ;
public int start ;
public int size ;
private static final Map<String, UnicodeBlock> block = new HashMap<String, UnicodeBlock>() ;
private UnicodeBlock( String name, String nice, int start, int size ) {
this.name = name
.trim()
.toUpperCase()
.replaceAll( \"[ _-]+\", \"_\" ) ;
this.nice = nice
.trim() ;
this.start = start ;
this.size = size ;
block.put( this.name, this ) ;
}
public static final UnicodeBlock forName( String name ) {
UnicodeBlock block ;
String[] legacyName = new String[] {
\"GREEK\",
\"COMBINING_MARKS_FOR_SYMBOLS\" } ;
String[] actualName = new String[] {
\"GREEK_AND_COPTIC\",
\"COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS\" } ;
block = UnicodeBlock.block.get( name
.trim()
.toUpperCase()
.replaceAll( \"[ _-]+\", \"_\") ) ;
if ( block == null )
for ( int n=0 ; n<legacyName.length ; n++ )
if ( name.equals( legacyName[n] ) ) {
block = UnicodeBlock.forName( actualName[n] ) ;
break ;
}
return block ;
}
"
gawk --posix '
$0~/^[0-9A-Fa-f]{4,6}\.\./ {
if ( split( $0, sv, /; / ) != 2 )
next ;
if ( split( sv[1], se, /\.\./ ) != 2 )
next ;
gsub( /^[ \t]*/, "", sv[2] );
gsub( /[ \t]*$/, "", sv[2] );
id = sv[2] ;
gsub( /[ _-]+/, "_", id ) ;
id = toupper( id ) ;
print " public static final UnicodeBlock " id " = "
print " new UnicodeBlock( \"" id "\", \"" sv[2] "\", 0x" se[1] ", 0x" se[2] "-0x" se[1] "+1 ) ; "
}' $1
echo "}"