#!/usr/bin/perl -w use strict; #this is just a tricky way to make a hash table # #translate something to something screams hash #table - we can get this from a file or wherever, #or just make a %TranslateTable declaration statement.. # #I didn't think that was the point here... my %TranslateTable = map { my ($char, $hmtl) = split} split /\n/, <<'END'; Á Á á á É É é é Í Í í í Ñ Ñ ñ ñ Ó Ó ó ó Ú Ú ú ú Ü Ü ü ü ¿ ¿ ¡ ¡ END my $s = "El supersÁnico de los Indi "; my $xlated = fix_utf8($s); print "$s\n"; print "****translated = $xlated\n"; ## this can be done in fewer lines, and could be faster, ## but I didn't think that was the point either.... ## ## this is simple and straightforward. ## maybe I misunderstood the problem, but even so ## there maybe something that you can use ## sorry, that I don't speak this language, perhaps ## there is a funny goof, if so laugh! OK! sub fix_utf8 { my $in_string = shift; my $newstring =""; foreach my $char (split (//,$in_string) ) { $char = $TranslateTable{$char} if $TranslateTable{$char}; $newstring .= $char; } return $newstring; } __END__ ######### prints El supersÁnico de los Indi ****translated = El supersÁnico de los Indi