On Saturday, Aug 9, 2003, at 00:08 Asia/Tokyo, Simon Cozens wrote:
This is sad and I ought to know the answer, but...

Can someone give me a few quick examples of creating Encode::XS objects
to do simple transcoding, from XS?

You should check the source of PerlIO::encoding (ext/PerlIO/encoding/encoding.xs) to see how to do so via XS. But I don't think you'd call it simple. Let me quote a few lines from there;


        PUSHMARK(sp);
        XPUSHs(e->enc);
        XPUSHs(e->dataSV);
        XPUSHs(e->chk);
        PUTBACK;
        if (call_method("decode", G_SCALAR) != 1) {
            Perl_die(aTHX_ "panic: decode did not return a value");
        }
        SPAGAIN;
        uni = POPs;

See? It does exactly what you would call an ordinary perl (sub|method)s from XS; you push arguments into the stack, call_method() and pop the result. In other words, there is no shortcut -- yet.

Dan the Encode Maintainer



Reply via email to