develooper Front page | perl.perl5.porters | Postings from July 2014

[perl #122308] pack propagates UTF8 strings

Thread Next
Mike L
July 17, 2014 07:14
[perl #122308] pack propagates UTF8 strings
Message ID:
# New Ticket Created by  Mike L 
# Please include the string:  [perl #122308]
# in the subject line of all future correspondence about this issue. 
# <URL: >

I know this is a consequence of an intended change in 5.10, but it breaks existing code in non-obvious ways - there should at least be documentation, if not an option to pack() to change this behavior.

If you pass a UTF8 encoded string to pack() the output of pack() is now a UTF8 encoded string. When the packed data is passed to another program the entire string gets encoded, including any binary data along with it.

Consider the attached program. It packs an integer and a string and sends the result over a message queue. Because the packed string has the UTF8 encoded attribute it gets encoded and the received string does not unpack to the correct values.

Having pack() handle UTF8 strings the way it does is only useful if the packed data is not sent outside the process, which is sort of the whole reason for pack in the first place...
Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About