<[EMAIL PROTECTED]> writes:
>Probably a newbie question. I had to modify a
>SvPV_nolen() to SvPVbyte_nolen() to get some code to
>work properly.
>
>What is the difference between SvPV_nolen() and
>SvPVbyte_nolen()? 

SvPV_nolen() returns char * to string part of a scalar in its 
current encoding state.

SvPVbyte_nolen() down-grades characters in range 0x80..0xFF which 
happen to have become UTF-8 encoded back to bytes first, by calling 

sv_utf8_downgrade(sv,0)

That function is accessable to perl as :
  utf8::downgrade($scalar,$failok)

So you could call that from perl before calling your XS.

>How do I get SvPVbyte_nolen() used
>for  a parameter instead of SvPV_nolen()?
>
>If the type of a parameter is T_PV in typemap, I get
>SvPV_nolen() for the parameter. What type should I use
>to get SvPVbyte_nolen() instead?

Hmm, nothing in the standard typemap so you need a custom one:
-----------------------------------------------------------------------------
unsigned char *     T_BYTE

INPUT
T_BYTE
        $var = ($type)SvPVbyte_nolen($arg)

OUTPUT
T_BYTE
        do { sv_setpv((SV*)$arg, $var); SvUTF8_off((SV *) arg); } while (0)

-----------------------------------------------------------------------------

Or you could write your XS to accept an SV and call the right things
in the CODE: section.



 

 

Reply via email to