in reply to Re^12: Determining content-length for an HTTP Post
in thread Determining content-length for an HTTP Post

Do you turn off use strict; and use warnings; when they start issuing messages?

Actually, I was hoping for a "Wide character in print ..." warning (and a correct Content-Length header). That would have solved the whole mystery ...

But enough of that. The funny thing is, I'm currently writing a web framework and one of the design decisions I have not made yet is whether to allow a character string as the response body or not, because of this whole bytes / print issue. So I would really like to see a real world example where Perl gets the length in bytes of a string wrong when compared to the number of bytes actually printed, assuming no PerlIO layer and no direct manipulation of the string's UTF-8 flag.

Replies are listed 'Best First'.
Re^14: Determining content-length for an HTTP Post
by Corion (Patriarch) on Nov 27, 2009 at 18:11 UTC

    This is only true if you output utf8 and your Perl is built to use utf8 as its internal Unicode representation. If any of the two changes, { use bytes; length } will not give the correct results anymore.