hi,
I had to convert several symbols from German alphabet to different represantation... and used something like this until now :
sub blah { $_ = shift; s/ä/ae/g; s/Ä/AE/g; s/ö/oe/g; s/Ö/OE/g; s/ü/ue/
+g; s/Ü/UE/g; s/ß/ss/g; $_ }
But I now need more complicated conversation so I started rewriting(see code below)... but after I thougt a litle bit I decided first to ask, may be there is easier way... these language depenend stuff has always been a black-box to me..
...reading pelrlocale and POSIX to clear out the things a little bit... may be u can help me..
This just from the scratch I even not tested it .. on the NT it seems that dosen't work.. (going to Linux console :") )
$tstr = 'abc äÄöÖüÜß test';
%subsTable = (
'ä' => 'ae', 'Ä' => 'AE', 'ö' => 'oe', 'Ö' => 'OE',
'ü' => 'ue', 'Ü' => 'UE', 'ß' => 'ss'
);
$notInSQL = qr{'|`|´|"|,|%|$};
$inSQL = qr{`|´|"|,|$};
sub blah {
my $str = shift;
my $regex = join "|", map quotemeta, keys %subsHash;
print $regex,"\n";
$regex = qr/$regex/;
$str =~ s/($regex)/$subsHash{$1}/g;
# if ($str =~ /^\s*(SELECT|INSERT|UPDATE|DELETE)/i ) { $str =~ s/$i
+nSQL/ /g }
# else { $str =~ s/$notInSQL/ /g };
#may be have to use tr/// here
return $str
};
print "orig : $tstr\n";
print blah($tstr)."\n";
these are not all symbols to be converted I'm expecting more to come...