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

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.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^37: Interleaving bytes in a string quickly
by ikegami (Patriarch) on Mar 01, 2010 at 18:56 UTC

    unpack 'H' requires bytes. Well, pretty much all of unpack does. That's the point. Just like interleave does.

    Note that it properly handles both string formats:

    $ perl -wle'$x="\x80"; for (1..2) { print unpack "H*", $x; utf8::upgra +de($x); }' 80 80

    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 don't understand this at all.

      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 don't understand this at all.

      This is what I mean:

      $a = ''; $a .= chr 1<<$_ for 0..63;; Dump $a;; SV = PVMG(0x37b528) at 0x3058a0 REFCNT = 1 FLAGS = (SMG,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x3cb90f8 "\1\2\4\10\20 @\302\200\304\200\310\200\320\200\340\2 +40\200\341\200\200\342\200\200\344 ... \200"\0Malformed UTF-8 character (byte 0xfe) in subroutine entry Malformed UTF-8 character (byte 0xfe) in subroutine entry Malformed UTF-8 character (byte 0xfe) in subroutine entry Malformed UTF-8 character (byte 0xfe) in subroutine entry Malformed UTF-8 character (byte 0xfe) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry Malformed UTF-8 character (byte 0xff) in subroutine entry [UTF8 "\x{1}\x{2}\x{4}\x{8}\x{10} @\x{80}\x{100}\x{200}\x{400}\x{800} \x{1000}\x{2000}\x{4000}\x{8000} \x{10000}\x{20000}\x{40000} CUR = 504 LEN = 512 MAGIC = 0x3c856c8 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = -1 print join '-', map ord( chop $a ), 1 .. 64;; 0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0- +0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0

      And:

      $a = ''; $a .= chr 1<<$_ for 0..63;; print length $a;; 64 $a = reverse $a;; Malformed UTF-8 character (byte 0xfe) in reverse at (eval 47) print length $a;; 75

      If Perl can't handle it, it's a bug, not a feature. And not something I would concern myself with trying to handle.

      Yet another, just another red herring.


      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.

        If Perl can't handle it, it's a bug, not a feature.

        You can't have a bug in a feature without having a feature.