#!/usr/bin/perl # describe_unicodes -- add human readable descriptions to unicodes # Copyright © 2005 Anton Zinoviev # 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. # If you have not received a copy of the GNU General Public License # along with this program, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; my $utf = "/usr/share/i18n/charmaps/UTF-8.gz"; sub debug { print STDERR "@_"; } if ($ARGV[0] eq "--help" || $ARGV[0] eq "-h") { print STDERR <) { $line++; last if (/^[[:space:]]*CHARMAP[[:space:]]*$/); } while () { $line++; last if (/^[[:space:]]*END[[:space:]]*CHARMAP[[:space:]]*$/); /\[[:space:]]+[^[:space:]]+[[:space:]]+(.*)/ or die "$0: $utf: syntax error on line $line: $_\n"; $descriptions{hex ($1)} = $2; } close UTF; my @output; open FILE, "$file" or die "$0: $file: $!\n"; while () { push (@output, $_) unless (/^\# U\+[0-9a-fA-F]+: [^ ]/); s/#.*//; while (/^.*?U\+([0-9a-fA-F]+)(.*)/) { push (@output, sprintf ("# U+%s: %s\n", $1, $descriptions{hex ($1)})); $_ = $2; } } close FILE; open FILE, ">$file" or die "$0: $file: $!\n"; foreach (@output) { print FILE; } close FILE;