Hrrm. I'm not well versed with LWP stuff. I went to that web site with a browser, typed in an English word and got back a Japanese word (in utf8) -- that's fine (the page source had nothing strange about it). I tried wget from the command line with the url string that you would post to get that same translation:
$ wget -O /tmp/junk 'http://babelfish.altavista.com/tr?trtext=tree&lp
+=en_ja'
and I think wget gave me the same output that went to the browser -- that's fine. (But when I tried again later, it gave me a null byte where the Japanese should have been. Having overwritten the original try, I can't be sure now.)
When I run your test script, $translation ends up with a null byte. I tried printing $result to STDERR, and redirected that to a file. The file (i.e. the full web page content returned by LWP->get) had null bytes where the browser (and maybe wget) output had a Japanese character.
So I'm guessing there is something wrong with how you are making or sending the request to the server, but I can't imagine what to try next in order to figure out the problem and fix it. Good luck.
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.