XS.xs 

for(i = 0; i < bytes; i++, ph++) {
    if((*ph & 0x80) == 0)
        continue;

    if(out == NULL) {
        out = newSV(bytes * 12 / 10);
        SvPOK_on(out);
    }

    if(ph > pt) {
        sv_catpvn(out, pt, (STRLEN)(ph - pt));
    }

    // ...
    pt = ph + 1;
}