| 1 |
#!/usr/bin/env perl |
| 2 |
# |
| 3 |
# Create a transliteration table for the TableTransliterator. |
| 4 |
# It just gets the values from the Test::Unidecode module of perl. |
| 5 |
# |
| 6 |
# Based on a script by Ævar Arnfjörð Bjarmason |
| 7 |
# |
| 8 |
|
| 9 |
use feature ':5.10'; |
| 10 |
use strict; |
| 11 |
use warnings; |
| 12 |
|
| 13 |
use Unicode::UCD 'charinfo'; |
| 14 |
use Text::Unidecode; |
| 15 |
use Data::Dump 'dump'; |
| 16 |
|
| 17 |
# |
| 18 |
# Based on a script by Ævar Arnfjörð Bjarmason |
| 19 |
# |
| 20 |
my $row = $ARGV[0]; |
| 21 |
#if (!$row) { |
| 22 |
# exit 1; |
| 23 |
#} |
| 24 |
|
| 25 |
sub new_trans { |
| 26 |
my $char_val = shift; |
| 27 |
|
| 28 |
my $t; |
| 29 |
if ($t = unidecode($char_val) and $t !~ /[?].*/) { |
| 30 |
return $t; |
| 31 |
} |
| 32 |
|
| 33 |
return "?"; |
| 34 |
} |
| 35 |
|
| 36 |
binmode STDOUT, ":utf8"; |
| 37 |
|
| 38 |
say <<EOF; |
| 39 |
# |
| 40 |
# A look up table to transliterate to ascii. |
| 41 |
# Created with the Text::Unidecode module of perl |
| 42 |
# |
| 43 |
EOF |
| 44 |
|
| 45 |
for (my $i = 0; $i < 256; $i++) { |
| 46 |
my $trans; |
| 47 |
|
| 48 |
my $c = $row * 256 + $i; |
| 49 |
$trans = new_trans(chr $c); |
| 50 |
|
| 51 |
my $char_name = sprintf("U+%02x%02x", $row, $i); |
| 52 |
if ($trans) { |
| 53 |
say sprintf("%s %-12.12s # Character %c", $char_name, |
| 54 |
$trans, $c); |
| 55 |
} else { |
| 56 |
say sprintf("%s %-12.12s # Character %c", $char_name, "?", |
| 57 |
$c); |
| 58 |
} |
| 59 |
} |