Skip to content

Commit

Permalink
#81 some unicode replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 18, 2024
1 parent 6a18ebf commit 4cc2e7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bibcop.pl
Expand Up @@ -736,6 +736,26 @@ sub fix_organization {
return $value;
}

sub fix_unicode {
my ($value) = @_;
my %literals = (
'ò' => '\`{o}', 'ó' => '\\\'{o}', 'ô' => '\^{o}', 'ö' => '\"{o}', 'ő' => '\H{o}', 'ǒ' => '\v{o}', 'õ' => '\~{o}',
'à' => '\`{a}', 'á' => '\\\'{a}', 'â' => '\^{a}', 'ä' => '\"{a}', 'å' => '\r{a}', 'ą' => '\k{a}', 'ǎ' => '\v{a}', 'ã' => '\~{a}',
'ù' => '\`{u}', 'ú' => '\\\'{u}', 'û' => '\^{u}', 'ü' => '\"{u}', 'ů' => '\r{u}', 'ǔ' => '\v{u}', 'ũ' => '\~{u}',
'ì' => '\`{i}', 'í' => '\\\'{i}', 'î' => '\^{i}', 'ï' => '\"{i}', 'ǐ' => '\v{i}', 'ĩ' => '\~{i}',
'ń' => '\\\'{n}', 'ň' => '\v{n}', 'ñ' => '\~{n}',
'ç' => '\c{c}',
'ł' => '\l{}',
'ı' => '{\i}',
'ø' => '\o{}'
);
keys %literals;
while(my($k, $v) = each %literals) {
$value =~ s/\Q$k\E/$v/g;
}
return $value;
}

# Parse the incoming .bib file and return an array
# of hash-maps, where each one is a bibentry.
sub entries {
Expand Down
2 changes: 2 additions & 0 deletions perl-tests/fixing.pl
Expand Up @@ -79,6 +79,8 @@ package bibcop;
fixes('month', 'mar', 'mar');
fixes('month', 'something', 'something');

fixes('unicode', 'Fernández, Luis and Peña, Rosalía', 'Fern\\\'{a}ndez, Luis and Pe\~{n}a, Rosal\\\'{i}a');

sub fixes {
my ($tag, $before, $expected) = @_;
my $fixer = "fix_$tag";
Expand Down

0 comments on commit 4cc2e7f

Please sign in to comment.