XS.xs 

static int consume_utf8_bytes(U8* in, U8* out) {
    UV  cp, bytes, i;
    U8 *d;

    if((in[0] & 0b11100000) == 0b11000000) {
        cp = in[0] & 0b00011111;
        bytes = 2;
    }
    else if((in[0] & 0b11110000) == 0b11100000) {
        cp = in[0] & 0b00001111;
        bytes = 3;
    }
    //...
    else {
        return(0);
    }