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

Hello fellow monks, I'm working on an RSS delivery script, and upon reading one of the headlines, my script aborts with this error:

Wide character in syswrite at /usr/lib/perl5/5.8.0/i386-linux-thread-multi/IO/Handle.pm line 445.

I attempted to do use bytes at the beginning of my script, to no avail. How can I fix this?

Thanks, -J

Replies are listed 'Best First'.
Re: Wide Characters??
by borisz (Canon) on Feb 18, 2004 at 18:46 UTC
    if it is desired to have wide chars do binmode $your_filehandle, ':utf8';. At best direct after open/sysopen. To just silence do no warnings 'utf8'; in your script.
    Boris
      Tried that, it doesn't work. I also removed the 'use warnings' from my script. Unfortuantely, the opening/closing is n modules deep and I'd really like to not modify module code if I don't have to.

      Thanks,
      --J
        Where does the wide character come from? You either need to tell perl that that output handle takes utf8 (with binmode or in the open), or if you want to treat that source of input as non-utf8, don't do whatever you are doing to make perl think it has utf8.

        If you are using perl5.8.0 and have your locale set as utf8 (as is the default under some OS's), either changing to a non-utf8 locale or upgrading perl may help.

        Note that use bytes is lexically scoped just like use warnings, and isn't a general panacea anyway; newer perls shouldn't encode things as utf8 unless they get lied to about the input.

Re: Wide Characters??
by William G. Davis (Friar) on Feb 18, 2004 at 20:59 UTC

    Did you use the three argument form of syswrite() or the two argument form?