For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > November 2007 > Help with transliteration









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help with transliteration
Ivan Bogdanov

2007-11-26, 8:01 am

Hi,

I have some problems with transliteration from Cyrillic text into
Latin.
I my mind, i have two ways to solve the problem:
1) using a tr/// operator, but it not the best way i think, because in
Russian it might be one symbol and in transit it would be two
symbols.
2) using two arrays, something like this:
my @cstring=3Dqw(=C1 =C2 =D7 =C7 =C4 =C5 =A3 =D6 =DA =C9 =CA =CB =CC =CD =
=CE =CF =D0 =D2 =D3 =D4 =D5 =C6 =C8 =C3 =DE =DB
=DD =DF =D9 =D8 =DC =C0 =D1);
my @lstring=3Dqw(a b v g d e yo g z i y k l m n o p r s t u f x c ch
sh shch ' yi ' e yu ya);

and then substitute each symbol. And here i have a problem.
Ohhh, i have a string like this - $string =3D "=F0=CF=D0=CF=D7 =F0 =F0", and=
i need to
convert it to $string =3D "Popov_PP". Can anybody help me with this?

Nobull67@Gmail.Com

2007-11-26, 8:01 am

On Nov 26, 9:43 am, bogdanov....@gmail.com (Ivan Bogdanov) wrote:
> Hi,
>
> I have some problems with transliteration from Cyrillic text into
> Latin.
> I my mind, i have two ways to solve the problem:
> 1) using a tr/// operator, but it not the best way i think, because in
> Russian it might be one symbol and in transit it would be two
> symbols.
> 2) using two arrays, something like this:
> my @cstring=3Dqw(=C1 =C2 =D7 =C7 =C4 =C5 =A3 =D6 =DA =C9 =CA =CB =CC =

=CD =CE =CF =D0 =D2 =D3 =D4 =D5 =C6 =C8 =C3 =DE =DB
> =DD =DF =D9 =D8 =DC =C0 =D1);
> my @lstring=3Dqw(a b v g d e yo g z i y k l m n o p r s t u f x c ch
> sh shch ' yi ' e yu ya);
>
> and then substitute each symbol. And here i have a problem.
> Ohhh, i have a string like this - $string =3D "=F0=CF=D0=CF=D7 =F0 =F0", a=

nd i need to
> convert it to $string =3D "Popov_PP". Can anybody help me with this?


Well, the characters in $string are not in @cstring so I'm not quite
sure how you expect that to work.

But if you just want to replace characters in @cstring with the
corresponding string in @lstring then you could do something like...

my %c2l;
@c2l{@cstring}=3D@lstring;
$string =3D~ s/(.)/$c2l{$1}||$1/eg;

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com