rjray/rpc-xml — pull request #5 by alexrj (2012-01-30 12:00:19+00:00)
Title: Use utf8::encode() instead of utf8::downgrade()

After updating to the most recent version of RPC::XML my applications broke. It looks like RPC::XML::Client is sending bad UTF-8 data.
I was using the `*RPC::XML::utf8_downgrade = \&utf8::encode;` hack but the recent RPC::XML updates made it useless.

Digging in the code, I noticed that RPC::XML::Client uses `utf8::downgrade()` to encode request data. After changing it to `utf8::encode()` everything is working again.

To check whether this change is good or not, I put these lines after the original call to `utf8::downgrade()`:

```
# Treat the content strictly in-memory
utf8::downgrade($content = $req->as_string);
open my $fh, ">", "foo.txt";
binmode $fh;
print $fh $content;
close $fh;
```

Inspecting the resulting file with a text editor showed that the file doesn't include UTF-8 octects but 8-bit data. After the change to `utf8::encode()` the file actually contained valid UTF-8 text.

I only replaced `utf8::downgrade()` in the place that affected my applications, but I see there are other occurrences in the module files. You might want to check whether it should be there or not.