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...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.