File: charclass.pl

package info (click to toggle)
yudit 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,472 kB
  • sloc: cpp: 76,344; perl: 5,630; makefile: 989; ansic: 823; sh: 441
file content (173 lines) | stat: -rwxr-xr-x 3,840 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/perl

#  Yudit Unicode Editor Source File
#
#  Copyright (C) 2000  Gaspar Sinai <gsinai@yudit.org>  
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# 
#  This script makes a compressed precompose map.
#  Compressed means: for a range only the first one will be 
#  encoded.
#  In order to run the script you need to get
#   ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
#  as and input.
#  encode composing chars -> precomposed char
#  decode precomposed char -> composing chars

%GeneralCategory = (
"Lu", 1,
"Ll", 2,
"Lt", 3,
"Mn", 4,
"Mc", 5,
"Me", 6,
"Nd", 7,
"Nl", 8,
"No", 9,
"Zs", 10,
"Zl", 11,
"Zp", 12,
"Cc", 13,
"Cf", 14,
"Cs", 15,
"Co", 16,
"Cn", 17,

# Informative Categories

"Lm", 18,
"Lo", 19,
"Pc", 20,
"Pd", 21,
"Ps", 22,
"Pe", 23,
"Pi", 24,
"Pf", 25,
"Po", 26,
"Sm", 27,
"Sc", 28,
"Sk", 29,
"So", 30
);

@encodes = ();
@decodes = ();

@full_date = localtime(time);
$year = $full_date[5] + 1900;
$mon = $full_date[4] + 1;
$mday = $full_date[3];
$date = sprintf ("%4d-%02d-%02d", $year, $mon, $mday);

die "No version specified." if ($#ARGV == -1);
$VERSION=shift;

print <<EOD;
NAME=charclass.my
COMM=
COMM= generated by $0 $date
COMM= 
COMM= from ftp://ftp.unicode.org/Public/$VERSION/uc/UnicodeData.txt 
COMM=

#  01 Lu Letter, Uppercase
#  02 Ll Letter, Lowercase
#  03 Lt Letter, Titlecase
#  04 Mn Mark, Non-Spacing
#  05 Mc Mark, Spacing Combining
#  06 Me Mark, Enclosing
#  07 Nd Number, Decimal Digit
#  08 Nl Number, Letter
#  09 No Number, Other
#  0A Zs Separator, Space
#  0B Zl Separator, Line
#  0C Zp Separator, Paragraph
#  0D Cc Other, Control
#  0E Cf Other, Format
#  0F Cs Other, Surrogate
#  10 Co Other, Private Use
#  11 Cn Other, Not Assigned (no characters in the file have this property)

# Informative Categories

#  12 Lm Letter, Modifier
#  13 Lo Letter, Other
#  14 Pc Punctuation, Connector
#  15 Pd Punctuation, Dash
#  16 Ps Punctuation, Open
#  17 Pe Punctuation, Close
#  18 Pi Punctuation, Initial quote(may behave like Ps or Pe depending on usage)
#  19 Pf Punctuation, Final quote (may behave like Ps or Pe depending on usage)
#  1A Po Punctuation, Other
#  1B Sm Symbol, Math
#  1C Sc Symbol, Currency
#  1D Sk Symbol, Modifier
#  1E So Symbol, Other
#
# This ia a compressed map: that means all characters in the range are
# represented by the first element only. Holes are represented with 0.
#
COMM=Informative Categories
COMM=Compressed Range Format
TYPE=0
SECTION=encode
ENCODE=1
#
# key 2 for 32 bit (32-bitunicode)
# value 0 for 8 bit (charclass) values 
#
KEY_WIDTH=2
VALUE_WIDTH=0
KEY_LENGTH=0
VALUE_LENGTH=0
EOD


$last = -1;
$lastvle = -2;

while (<>)
{
  @_ = split(';', $_);
  next if ($#_ < 6);

  $plain = hex $_[0];
  $general = $_[2];
  if (!defined ($GeneralCategory {$general}))
  {
    $general = 0;
  }
  else
  {
    $general = $GeneralCategory {$general};
  }
  if ($last+1 == $plain && $lastvle == $general)
  {
    $last++;
    next;
  }  
  # hole
  if ($last+1 < $plain && $_[1]!~/Last>/)
  {
    printf ("%08X -> %02X$/", $last+1, 0);
  }
  printf ("%08X -> %02X$/", $plain, $general);
  $last = $plain;
  $lastvle = $general;
}
printf ("%08X -> %02X$/", $last+1, 0);

print "$/#END$/";