On Jul 15, 2004, at 10:31 AM, Pascal Oberndoerfer wrote:

I used to install MIME-tools 5.411a via the CPAN shell on MacOS X 10.2.8
(and 10.1.5) without any problems.


Trying to do the same on MacOS X 10.3.4 ends with an error while doing 'make
test'. The error can be seen in Ref.tlog:

It looks like MIME::Tools is tripping over Perl 5.8's UTF8 support.

Looking through MIME::Tools, it appears that it manually encodes UTF8 strings by inserting the necessary escapes into ordinary ASCII strings. This worked (and was necessary) with earlier Perls, because they didn't know about UTF8 - ASCII bytes were passed as-is to system calls that are UTF8-aware, and those system calls figured out the UTF8 encoding.

Beginning with 5.8, Perl understands the difference between ASCII and UTF8. When passing an ASCII string to a system function it knows is UTF8-aware, it encodes the contents of the string as UTF8. UTF8 escape sequences found in the ASCII string aren't interpreted as such - they're escaped again, so that the result is a UTF8 representation of the text in the string, complete with backslashes and hex numbers.

One fix would be to use 5.8's utf8::upgrade() function. That sets Perl's UTF8 flag for ASCII strings that have been manually encoded, so that it interprets the bytes in them as UTF8. A better fix might be to use 5.8's utf8::encode() function instead of manually encoding strings to begin with.

sherm--



Reply via email to