develooper Front page | perl.perl5.porters | Postings from February 2021

SvPV in perlapi?

Thread Next
From:
Felipe Gasper
Date:
February 16, 2021 21:30
Subject:
SvPV in perlapi?
Message ID:
871904F0-F6C3-4ECB-93A8-BE0DB3614671@felipegasper.com
Hi all,

I’ve fixed some bugs today that arose from use of SvPV in XS code rather than SvPVbyte. The fixes involved either sending patches upstream or prefixing our XS call with Perl utf8::downgrade() on the strings.

How frequently is SvPV the right choice rather than SvPVbyte or SvPVutf8? It seems … rare … that the C code should want to work on different bytes depending on how Perl stores the string.

If that’s true, should perlapi.pod’s description of SvPV be updated to encourage XS newbies to prefer one of the others instead? e.g., “Unless you care about how Perl stores the string internally, prefer SvPVbyte (for encoded strings) or SvPVutf8 (for decoded strings).”

Thank you!

-FG
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About