For those who want some code to play with:
#!/usr/bin/perl
use URI::Escape;
use Encode;
require LWP::UserAgent;
my $escape = uri_escape(join('. ', @ARGV));
my $ua = LWP::UserAgent->new;
my $response = $ua->get("http://babelfish.altavista.com/tr?trtext=$esc
+ape&lp=en_ja");
if ($response->is_success) {
$result = $response->content; # or whatever
} else {
die $response->status_line;
}
Encode::_utf8_on( $result );
my ($translation) = $result =~ /\Q<td bgcolor=white class=s><div style
+=padding:10px;>\E(.+?)\Q<\/div>\E/;
$original = $translation;
$translation=~s/([^[:ascii:]])/sprintf("\\x{%.4x}",ord $1)/ge;
print $translation ."\n". length($original) ."\n". ord(substr($origina
+l,0,1));
Run this (at least on my machine) and $translation has no visible contents, yet it has a length of 5!
If your machine gives you something sensible, please let me know.
(You can probably remove the Encode calls there .. that was just making sure that the resulting string *was* in utf8 according to perl)
Cheers!
Rick
If this is a root node: Before responding, please ensure your clue bit is set.
If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.
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.