3 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 # National Institute of Advanced Industrial Science and Technology (AIST)
5 # Registration Number H13PRO009
7 # This file is part of GNU Emacs.
9 # GNU Emacs is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # GNU Emacs is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 # Convert charset map of various format into this:
27 # XX is a code point of the charset in hexa-decimal,
28 # YYYY is the corresponding Unicode character code in hexa-decimal.
31 # $2: address pattern for sed (optionally with substitution command)
32 # $3: format of source map file
33 # GLIBC-1 GLIBC-2 GLIBC-2-7 CZYBORRA IANA UNICODE UNICODE2 YASUOKA
36 FILE
="admin/charsets/$1"
37 BASE
=`basename $1 .gz`
41 FILE
="$BASE in localedate/charmaps of glibc";
45 SOURCE
="http://czyborra.com/charsets/${BASE}";;
47 SOURCE
="http://www.iana.org/assignments/charset-reg/${BASE}";;
49 SOURCE
="http://www.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/${BASE}";;
51 SOURCE
="http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/${BASE}";;
54 SOURCE
="http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/ftp/CJKtable/${BASE}";;
56 SOURCE
="http://kanji-database.cvs.sourceforge.net/viewvc/*checkout*/kanji-database/kanji-database/data/cns2ucsdkw.txt?revision=1.4";;
58 echo "Unknown file type: $3";
62 if [ -n "$SOURCE" ] ; then
63 echo "# Generated from $FILE which is a copy of";
66 echo "# Generated from $FILE"
74 echo "Awk program does not exist: $4"
81 if [ "$3" = "GLIBC-1" ] ; then
84 zcat
$1 |
sed -n -e "$2 p" \
85 |
sed -e 's,<U\([^>]*\)>[ ]*/x\(..\).*,0x\2 0x\1,' \
87 elif [ "$3" = "GLIBC-2" ] ; then
90 zcat
$1 |
sed -n -e "$2 p" \
91 |
sed -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
93 elif [ "$3" = "GLIBC-2-7" ] ; then
96 # We must drop MSBs of XX and ZZ
97 zcat
$1 |
sed -n -e "$2 p" \
98 |
sed -e 's/xa/x2/g' -e 's/xb/x3/g' -e 's/xc/x4/g' \
99 -e 's/xd/x5/g' -e 's/xe/x6/g' -e 's/xf/x7/g' \
100 -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
103 elif [ "$3" = "CZYBORRA" ] ; then
106 zcat
$1 |
sed -n -e "$2 p" \
107 |
sed -e 's/=\(..\)[^U]*U+\([0-9A-F]*\).*/0x\1 0x\2/' \
109 elif [ "$3" = "IANA" ] ; then
112 zcat
$1 |
sed -n -e "$2 p" \
113 |
sed -e 's/\(0x[0-9A-Fa-f]*\)[^0]*\(0x[0-9A-Fa-f]*\).*/\1 \2/' \
115 elif [ "$3" = "UNICODE" ] ; then
118 # We perform reverse sort to prefer the first one in the
119 # duplicated mappings (e.g. 0x20->U+0020, 0x20->U+00A0).
120 zcat
$1 |
sed -n -e "$2 p" \
121 |
sed -e 's/\([0-9A-F]*\)[^0-9A-F]*\([0-9A-F]*\).*/0x\2 0x\1/' \
123 elif [ "$3" = "UNICODE2" ] ; then
125 # 0xXXXX 0xYYYY # ...
126 zcat
$1 |
sed -n -e "$2 p" \
127 |
sed -e 's/\([0-9A-Fx]*\)[^0]*\([0-9A-Fx]*\).*/\1 \2/' \
128 |
${AWKPROG} |
sort -n -k 4,4
129 elif [ "$3" = "YASUOKA" ] ; then
131 # YYYY 0-XXXX (XXXX is a Kuten code)
132 zcat
$1 |
sed -n -e "$2 p" \
133 |
sed -e 's/\([0-9A-F]*\)[^0]*0-\([0-9]*\).*/0x\2 0x\1/' \
135 elif [ "$3" = "KANJI-DATABASE" ] ; then
137 # C?-XXXX U+YYYYY .....
138 zcat
$1 |
sed -n -e "$2 p" \
139 |
sed -e 's/...\(....\) U+\([0-9A-F]*\).*/0x\1 0x\2/' \
142 echo "Invalid arguments: $3"
146 # arch-tag: c33acb47-7eb6-4872-b871-15e1447e8f0e