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

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.

Replies are listed 'Best First'.
Re^38: Interleaving bytes in a string quickly
by BrowserUk (Patriarch) on Mar 01, 2010 at 21:59 UTC
    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.

        If you regard the fact that you can currently get away with passing silly numbers to chr, as a feature, then every other operation that you can apply to a string, contains a bug. That's lots of bugs.

        At best, you've describe a terminally broken feature. More likely, simply a bug.

        And along the way, wasted a lot of people's time in the process. By drip-feeding obscure hints and innuendos, instead of posting a simple, clear explanation of what you were alluding to.

        Do not bother replying further, because I'm not interested in your games anymore.


        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.