int Encoding::mbclen(const uint8_t* p, const uint8_t* e, OnigEncodingType* enc) { int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); if (ONIGENC_MBCLEN_CHARFOUND_P(n) && ONIGENC_MBCLEN_CHARFOUND_LEN(n) <= e-p) { return ONIGENC_MBCLEN_CHARFOUND_LEN(n); } else { int min = ONIGENC_MBC_MINLEN(enc); return min <= e-p ? min : (int)(e-p); } }
extern int onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc) { int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e); if (ONIGENC_MBCLEN_CHARFOUND_P(ret)) return ONIGENC_MBCLEN_CHARFOUND_LEN(ret); else if (ONIGENC_MBCLEN_NEEDMORE_P(ret)) return (int)(e-p)+ONIGENC_MBCLEN_NEEDMORE_LEN(ret); return 1; }
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) { int n; if (e <= p) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1); n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); if (e-p < n) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(int)(e-p)); return n; }
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc) { int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); if (MBCLEN_CHARFOUND_P(n) && MBCLEN_CHARFOUND_LEN(n) <= e-p) return MBCLEN_CHARFOUND_LEN(n); else { int min = rb_enc_mbminlen(enc); return min <= e-p ? min : (int)(e-p); } }
int Encoding::precise_mbclen(const uint8_t* p, const uint8_t* e, OnigEncodingType* enc) { int n; if (e <= p) { return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1); } n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); if (e-p < n) { return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(int)(e-p)); } return n; }