in reply to Re^32: Interleaving bytes in a string quickly
in thread Interleaving bytes in a string quickly

Even with your misspeak, that's just a bug in Perl.

use Devel::Peek;; $a = '';; $a = chr( 65 );; Dump $a;; SV = PV(0x11cfc0) at 0x11f248 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x3d6ccc8 "A"\0 CUR = 1 LEN = 8 $a .= chr( 2**32 );; Dump $a;; SV = PV(0x11cfc0) at 0x11f248 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x3d6cbd8 "A\376\204\200\200\200\200\200"\0Malformed UTF-8 char +acter (byte 0xfe) in subroutine entry [UTF8 "A\x{0}"] CUR = 8 LEN = 16

It allows you to construct a malformed utf-8 (unicode) string. It shouldn't.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^34: Interleaving bytes in a string quickly
by ikegami (Patriarch) on Mar 01, 2010 at 18:13 UTC
    Concerning that warning, it's seen as a tool if you're dealing with unicode characters (although a buggy one atm), one that you can turn off if you're dealing with strings of numbers.
Re^34: Interleaving bytes in a string quickly
by ikegami (Patriarch) on Mar 01, 2010 at 18:07 UTC

    that's just a bug in Perl.

    No, it's quite intentional.

    If anything, the warning is seen as the bug.

      No, it's quite intentional.

      For what purpose?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Whatever purpose you want, not just unicode strings.

        That makes no sense at all. It breaks everything:

        pp \$a;; [Malformed UTF-8 character (fatal) at C:/Perl64/lib/Data/Dump.pm line +458, <STDIN> line 13. print unpack 'H*', $a;; Malformed UTF-8 character (byte 0xfe) in unpack at (eval 21) line 1, < +STDIN> line 14. Malformed UTF-8 character (unexpected continuation byte 0x84, with no +preceding start byte) in unpack Malformed UTF-8 character (unexpected continuation byte 0x80, with no +preceding start byte) in unpack Malformed UTF-8 character (unexpected continuation byte 0x80, with no +preceding start byte) in unpack Malformed UTF-8 character (unexpected continuation byte 0x80, with no +preceding start byte) in unpack Malformed UTF-8 character (unexpected continuation byte 0x80, with no +preceding start byte) in unpack Malformed UTF-8 character (unexpected continuation byte 0x80, with no +preceding start byte) in unpack 4100000000000000

        And perl already has a perfectly good mechanism for packing integers into strings.

        It also means that you now have a mechanism that will allow you to construct a string of packed integers that Perl has no way of unambiguously deconstructing.

        I look forward to seeing that deperecated & removed sometime soon.

        And it has no bearing upon the original desicussion because SvPVbytes() wouldn't know what to do with it either.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.