Dominic Mitchell <[EMAIL PROTECTED]> writes:

> I'm trying to upload a file to a server, but it's failing because the
> content-length is incorrect.  This is because the content is UTF-8 and
> length() is reporting characters, not bytes.

You are not supposed to provide content with chars outside the 0..255
range.

> Attached is a small test to demonstrate this.
> 
> I would imagine that somewhere in the bowels of HTTP::Request,
> bytes::length() needs to be used instead of the default
> CORE::length(), which reports characters.  Or maybe call
> decode('utf8', $content).  But that would involve knowing more about
> the character sets in use...

Assuming you mean encode here.  This would be wrong.  I don't think
LWP should assume any charset for you or expose perl's internal
representation.  Just call encode() on the content you pass to LWP
yourself.

Regards,
Gisle

Reply via email to