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

Yes, but SvPVX won't.

You're still at it aren't you. Trying to pretend (or at least imply), that you know something special. Back there a ways I was willing to give you the benefit of the doubt, so I asked you to explain yourself. You haven't.

So, I'll make an assertion: SvPVX cannot treat it's target SV as anything! Bytes. UTF_whatever. Or flying ducks.

All SvPVX can do is return the address held in the pv slot, or die if it is a readonly scalar.


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"
  • Comment on Re^15: Interleaving bytes in a string quickly

Replies are listed 'Best First'.
Re^16: Interleaving bytes in a string quickly
by ikegami (Patriarch) on Feb 28, 2010 at 23:05 UTC

    I asked you to explain yourself. You haven't.

    You seem to have missed Re^8: Interleaving bytes in a string quickly? If sv contains the byte string "\x80\x81", the pointer returned by SvPVX(sv) points to one of the following:

    • two bytes 80 81*
    • three bytes 80 81 00
    • four bytes C2 80 C2 81*
    • five bytes C2 80 C2 81 00

    * — These tend to be considered bugs.

      Nope. I didn't miss it. I just didn't believe that you could get things so arse backward.

      (Sorry about this, but the point needs to be stated clearly!), SvPVX() performs NO COERCIONS WHATSOEVER!.

      Which makes that impossible. I therefore invite you to prove your assertion with code!


      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.

        SvPVX() performs NO COERCIONS WHATSOEVER

        I know. It just doesn't necessarily return a pointer to the bytes of a byte string.

        I therefore invite you to prove your assertion with code!

        Well, I don't know of anything that omits the \0, so the remaining two can be shown using:

        my $byte_string = "\x80\x81"; dump_sv_pvx($byte_string); utf8::upgrade($byte_string); dump_sv_pvx($byte_string);

        Any function or PerlIO layer is free to do format switch, even if the string only contains bytes. It doesn't change the string at all. It's still the same string of bytes.

        You didn't specify where the string came from. Maybe it came from lcss, for example, which can switch the internal format. (You discussed using lcss recently, IIRC.) If you need a specific format (and you do), SvPVX without a preceding format check is buggy.