
1arryb
User
Feb 26, 2009, 2:32 PM
Post #5 of 5
(1673 views)
|
|
Re: [shawnhcorey] Matrix for character substitution
[In reply to]
|
Can't Post
|
|
Shawn, I think you're onto something. But maybe:
my %hash_example = ( ñ => 'n', Ñ => 'N', ú => 'u', ó => 'o', ¿ => '', · => '-' ); my $xtr = "<some non-english string>"; my $estr = ''; # Translate each character in the xstr, one at a time. Substitute '?' for untranslatable characters. map { $estr .= $hash_example{$_} ? $hash_example{$_} : '?' } split('', $xstr); print "xstr=$xstr, estr=$estr\n"; UPDATE: Perhaps it's better to leave untranslatable (or English) characters unchanged:
map { $estr .= $hash_example{$_} ? $hash_example{$_} : $_ } split('', $xstr); Cheers, Larry
(This post was edited by 1arryb on Feb 26, 2009, 2:42 PM)
|