File: make-transliteration-table.pl

package info (click to toggle)
mkgmap 0.0.0%2Bsvn4905-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,032 kB
  • sloc: java: 73,856; xml: 1,695; python: 713; sh: 240; makefile: 149; perl: 31
file content (59 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/env perl
#
# Create a transliteration table for the TableTransliterator.
# It just gets the values from the Test::Unidecode module of perl.
#
# Based on a script by Ævar Arnfjörð Bjarmason
#

use feature ':5.10';
use strict;
use warnings;

use Unicode::UCD 'charinfo';
use Text::Unidecode;
use Data::Dump 'dump';

#
# Based on a script by Ævar Arnfjörð Bjarmason
#
my $row = $ARGV[0];
#if (!$row) {
#	exit 1;
#}

sub new_trans {
    my $char_val = shift;

	my $t;
	if ($t = unidecode($char_val) and $t !~ /[?].*/) {
		return $t;
	}

    return "?";
}

binmode STDOUT, ":utf8";

say <<EOF;
#
# A look up table to transliterate to ascii.
# Created with the Text::Unidecode module of perl
#
EOF

for (my $i = 0; $i < 256; $i++) {
	my $trans;
	
	my $c = $row * 256 + $i;
	$trans = new_trans(chr $c);

	my $char_name = sprintf("U+%02x%02x", $row, $i);
	if ($trans) {
		say sprintf("%s %-12.12s # Character %c", $char_name,
			$trans, $c);
	} else {
		say sprintf("%s %-12.12s # Character %c", $char_name, "?",
			$c);
	}
}