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 2, or (at your option)
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; see the file COPYING. If not, write to the
21 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
25 # Convert charset map of various format into this:
28 # XX is a code point of the charset in hexa-decimal,
29 # YYYY is the corresponding Unicode character code in hexa-decimal.
32 # $2: address pattern for sed (optionally with substitution command)
33 # $3: format of source map file
34 # GLIBC-1 GLIBC-2 GLIBC-2-7 CZYBORRA IANA UNICODE YASUOKA MICROSOFT
41 SOURCE
="glibc-2.3.2/localedata/charmaps/${BASE}";;
43 SOURCE
="http://czyborra.com/charsets/${BASE}";;
45 SOURCE
="http://www.iana.org/assignments/charset-reg/${BASE}";;
47 SOURCE
="http://www.unicode.org/Public/MAPPINGS/.../${BASE}";;
49 SOURCE
="http://www.unicode.org/Public/MAPPINGS/.../${BASE}";;
51 SOURCE
="http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/.../${BASE}";;
53 SOURCE
="http://www.microsoft.com/globaldev/reference/oem/${BASE}";;
55 SOURCE
="data at http://sourceforge.net/cvs/?group_id=26261";;
57 echo "Unknown file type: $3";
61 echo "# Generated from $SOURCE"
67 echo "Awk program does not exist: $4"
74 if [ "$3" == "GLIBC-1" ] ; then
77 sed -n -e "$2 p" < $1 \
78 |
sed -e 's,<U\([^>]*\)>[ ]*/x\(..\).*,0x\2 0x\1,' \
80 elif [ "$3" == "GLIBC-2" ] ; then
83 sed -n -e "$2 p" < $1 \
84 |
sed -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
86 elif [ "$3" == "GLIBC-2-7" ] ; then
89 # We must drop MSBs of XX and ZZ
90 sed -n -e "$2 p" < $1 \
91 |
sed -e 's/xa/x2/g' -e 's/xb/x3/g' -e 's/xc/x4/g' \
92 -e 's/xd/x5/g' -e 's/xe/x6/g' -e 's/xf/x7/g' \
93 -e 's,<U\([^>]*\)>[ ]*/x\(..\)/x\(..\).*,0x\2\3 0x\1,' \
96 elif [ "$3" == "CZYBORRA" ] ; then
99 zcat
$1 |
sed -n -e "$2 p" \
100 |
sed -e 's/=\(..\)[^U]*U+\([0-9A-F]*\).*/0x\1 0x\2/' \
102 elif [ "$3" == "IANA" ] ; then
105 sed -n -e "$2 p" < $1 \
106 |
sed -e 's/\(0x[0-9A-Fa-f]*\)[^0]*\(0x[0-9A-Fa-f]*\).*/\1 \2/' \
108 elif [ "$3" == "UNICODE" ] ; then
111 sed -n -e "$2 p" < $1 \
112 |
sed -e 's/\([0-9A-F]*\)[^0-9A-F]*\([0-9A-F]*\).*/0x\2 0x\1/' \
114 elif [ "$3" == "UNICODE2" ] ; then
116 # 0xXXXX 0xYYYY # ...
117 sed -n -e "$2 p" < $1 \
118 |
sed -e 's/\([0-9A-Fx]*\)[^0]*\([0-9A-Fx]*\).*/\1 \2/' \
119 |
${AWKPROG} |
sort -n -k 4,4
120 elif [ "$3" == "YASUOKA" ] ; then
122 # YYYY 0-XXXX (XXXX is a Kuten code)
123 sed -n -e "$2 p" < $1 \
124 |
sed -e 's/\([0-9A-F]*\)[^0]*0-\([0-9]*\).*/0x\2 0x\1/' \
126 elif [ "$3" == "MICROSOFT" ] ; then
129 sed -n -e "$2 p" < $1 \
130 |
sed -e 's/\([0-9A-F]*\).*U+\([0-9A-F]*\).*/0x\1 0x\2/' \
132 elif [ "$3" == "KANJI-DATABASE" ] ; then
134 # C?-XXXX U+YYYYY .....
135 sed -n -e "$2 p" < $1 \
136 |
sed -e 's/...\(....\) U+\([0-9A-F]*\).*/0x\1 0x\2/' \
139 echo "Invalid arguments"
143 # arch-tag: c33acb47-7eb6-4872-b871-15e1447e8f0e