Hi,

I'm trying to reproduce in an XSUB what Perl 5.8.0's built-in print() function does with regard to being given "flagged" UTF-8 data. (Namely, when the filehandle has a ":utf8" layer, it upgrades the data to UTF-8 before output; otherwise, if the "bytes" pragma is not in effect, it downgrades any UTF-8 data to the machine's native 8-bit encoding before output. (I think.))

I think I've found where Perl does this -- Perl_do_print() in "doio.c" -- and wanted to copy the chunk of code concerned:

if (PerlIO_isutf8(fp)) {
if (!SvUTF8(sv))
sv_utf8_upgrade(sv = sv_mortalcopy(sv));
}
else if (DO_UTF8(sv)) {
if (!sv_utf8_downgrade((sv = sv_mortalcopy(sv)), TRUE)
&& ckWARN_d(WARN_UTF8))
{
Perl_warner(aTHX_ packWARN(WARN_UTF8), "Wide character in print");
}
}


However, when I try to link this I get an "unresolved external symbol" error regarding PerlIO_isutf8(). This is declared in "perlio.h" (hence the compiler was happy), but listing the symbols exported by my "perl58.lib" I don't see it (hence the linker is unhappy).

Where is PerlIO_isutf8() to be found, and can it be accessed at all from XS?

If not, then how do I do what I'm trying to do here?

Thanks,

Steve

Reply via email to