spring has asked for the wisdom of the Perl Monks concerning the following question:

when I run a script like this  print "hello, world!";, there is always an error message:  panic: utf16_to_utf8: odd bytelen 5 at test.pl line xx. But perl in my PC works well on many scripts. Just it could gives such kind of problems. So what is going one there? thanks much.

Replies are listed 'Best First'.
Re: panic error message
by Fletch (Bishop) on May 30, 2007 at 19:35 UTC

    Not a solution, but quoth perldiag:

           panic: utf16_to_utf8: odd bytelen
               (P) Something tried to call utf16_to_utf8 with an odd (as opposed
               to even) byte length.
    

    So somehow you've got Perl thinking your text is UTF16 encoded (two octets per character) but it's got an odd number of bytes to work with (5 in this case). Perhaps your editor's inserting a specious BOM or something that's confuzzling Perl? (Disclaimer: I don't really have any experience with non-ASCII encodings, so take that for what it is (a literal reading of the error message text))

Re: panic error message
by Joost (Canon) on May 30, 2007 at 19:50 UTC
Re: panic error message
by blazar (Canon) on May 30, 2007 at 21:48 UTC

    AFAICS it shouldn't happen, that is: you shouldn't get into unicode trouble unless you explicitly ask for it. But then this may depend on you perl version (under some osen/environments). Isn't it by any chance 5.8.0?

Re: panic error message
by graff (Chancellor) on May 31, 2007 at 01:44 UTC
    You should show us the actual "test.pl" script, the exact error message (with the actual line number instead of "xx"), and make it clear in posting "test.pl" exactly where the cited line number is in the script.

    If you just do this at the shell command line, I expect that you won't get an error:

    perl -le 'print "hello, world!"'

    So the question is, what does your "test.pl" do besides that? No solution to your problem, until you show us more info (or figure it out on your own).

Re: panic error message
by spring (Novice) on May 31, 2007 at 15:42 UTC
    Thank you all very much. I got it now. It was due to the editor problem. cheers!!
Re: panic error message
by BenHopkins (Sexton) on May 31, 2007 at 05:48 UTC
    I googled your error message and found the answer right away.