http://qs321.pair.com?node_id=906388


in reply to Simplest Possible Way To Disable Unicode

That is a fascinating topic. I've run into that error from time to time, and others get it in a different situation from you: when the internal data is already known to be the same as how it should be written (UTF-8).

I think Perl has ratcheted up its features and gradually changed things, and you skipped too many generations in one go.

What version are you using now? The latest 5.14?

I think lots of us would like to discuss or at least see how "wide" data comes to be (you didn't store a funny character directly, right?) and what can control that.

So, it would be especially good if you could post a trivial program that does some manipulation (that's not obviously referring to any wide characters directly), writes it out, and gets that error.

  • Comment on Re: Simplest Possible Way To Disable Unicode

Replies are listed 'Best First'.
Re^2: Simplest Possible Way To Disable Unicode
by ikegami (Patriarch) on May 24, 2011 at 00:42 UTC

    when the internal data is already known to be the same as how it should be written (UTF-8).

    syswrite and print print the string, not its internal data. The internal storage format is not relevant here.

    >perl -we"$_ = chr(0xE9); utf8::downgrade($_); print;" | perl -nE"say +length;" 1 >perl -we"$_ = chr(0xE9); utf8::upgrade($_); print;" | perl -nE"say le +ngth;" 1 >perl -we"$_ = chr(1000); utf8::upgrade($_); print;" | perl -nE"say le +ngth;" Wide character in print at -e line 1. 2