Hello,
Can anyone think of a better way of addressing the following problem. I have a form and any name can be submitted - including ones with accents and special characters - the names are then used later on in the script to generate a latex template using a system call. However, latex handles special characters differently, for example ü is wriiten as \'"{u}. Therefore, as a enter the function i want to substutite any accent characters with the equilavant code. This is what i have come up with but i'm sure there is a better way of doing this:
my @special_characters = ("ü","Ü","ç","Ç","ä","Ä","é","É"
my %character_map = ( "ü", "\\\"{u}",
"Ü", "\\\"{U}",
"ç", "\\c{c}",
"Ç", "\\c{C}",
"ä", "\\\"{a}",
"Ä", "\\\"{A}",
"é", "\\'{e}",
"É", "\\'{E}" foreach my $el (@special_characters){ if ($author =~ /($el)/){
my $letter = $character_map{$el};
$author =~ s/$1/$letter/g;
}
}
has anyone any suggestions?
jim
Can anyone think of a better way of addressing the following problem. I have a form and any name can be submitted - including ones with accents and special characters - the names are then used later on in the script to generate a latex template using a system call. However, latex handles special characters differently, for example ü is wriiten as \'"{u}. Therefore, as a enter the function i want to substutite any accent characters with the equilavant code. This is what i have come up with but i'm sure there is a better way of doing this:
my @special_characters = ("ü","Ü","ç","Ç","ä","Ä","é","É"
my %character_map = ( "ü", "\\\"{u}",
"Ü", "\\\"{U}",
"ç", "\\c{c}",
"Ç", "\\c{C}",
"ä", "\\\"{a}",
"Ä", "\\\"{A}",
"é", "\\'{e}",
"É", "\\'{E}" foreach my $el (@special_characters){ if ($author =~ /($el)/){
my $letter = $character_map{$el};
$author =~ s/$1/$letter/g;
}
}
has anyone any suggestions?
jim