On Sep 5, 2013, at 11:14 PM, Nikolay Mishin <[email protected]> wrote: > Руслан, круто, так работает > > use utf8; > use open OUT => ':encoding(cp1251)';
+use open qw<:std>;
>
> sub translate_text {
> my ( $from, $to, $words ) = @_;
>
> my $url =
> 'http://translate.google.com/translate_t?langpair='
> . $from . '|'
> . $to
> . '&text=' . '+'
> . $words;
> my $ua = LWP::UserAgent->new;
> $ua->agent('');
> my $res = $ua->get($url);
> die $res->status_line if $res->is_error;
> my $html = $res->decoded_content;
>
> my @matches =
> $html =~
> m{onmouseout="this.style.backgroundColor='#fff'">(.*?)</span>}g;
>
> foreach my $translated_string (@matches) {
> say $translated_string;
> }
> }
>
> https://github.com/mishin/gists/blob/master/gtrans2.pl
> но
> $./gtrans2.pl --from en --to ru --text "This is a test"
> Wide character in say at ./gtrans2.pl line 63.
> Это тест
>
> 05.09.2013, 22:50, "Ruslan Zakirov" <[email protected]>:
>> ->decoded_content и use open OUT => ':encoding(cp1251)';
>>
>> Тогда совсем можно не заморачиваться :)
>>
>>
>> 2013/9/5 Anton Nikishaev <[email protected]>
>>
>> On Sep 5, 2013, at 10:16 PM, Nikolay Mishin <[email protected]> wrote:
>>
>> > Encode::from_to( $translated_string, 'koi8', 'cp1251' );
>> >
>> > $perl gtrans.pl --from=en --to=ru --text='This is a test'
>> > Unknown encoding 'KOI8' at gtrans.pl line 63
>> Она называется koi8-r
>>
>>
>> > 05.09.2013, 20:01, "Олег Алексеенков" <[email protected]>:
>> >> Nikolay Mishin <[email protected]> писал(а) в своём письме Thu, 05 Sep 2013
>> >> 08:38:50 +0400:
>> >>
>> >>> вопрос, можно ли строку
>> >>> Convert::Cyrillic::cstocs( 'KOI8', 'UTF8', $translated_string );
>> >>> Encode::from_to( $interm_var, 'utf-8', 'cp1251' );
>> >>> заменить одним преобразованием, чтобы на выходе был win1251?
>> >>> у меня этого не получилось
>> >>
>> >> а почему не работает
>> >> Encode::from_to( $interm_var, 'koi8', 'cp1251' );
>> >> ?
>> >> --
>> >> Moscow.pm mailing list
>> >> [email protected] | http://moscow.pm.org
>> >
>> > --
>> > С уважением
>> > Николай Мишин
>> >
>> > --
>> > Moscow.pm mailing list
>> > [email protected] | http://moscow.pm.org
>>
>> --
>> Moscow.pm mailing list
>> [email protected] | http://moscow.pm.org
>>
>>
>>
>> --
>> Best regards, Ruslan.
>> ,
>> --
>> Moscow.pm mailing list
>> [email protected] | http://moscow.pm.org
>>
>
>
> --
> С уважением
> Николай Мишин
>
> --
> Moscow.pm mailing list
> [email protected] | http://moscow.pm.org
signature.asc
Description: Message signed with OpenPGP using GPGMail
-- Moscow.pm mailing list [email protected] | http://moscow.pm.org
