diff options
Diffstat (limited to 'regenc.c')
-rw-r--r-- | regenc.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -52,6 +52,21 @@ onigenc_set_default_encoding(OnigEncoding enc) } extern int +onigenc_mbclen(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc) +{ + int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc, p, e); + if (ONIGENC_MBCLEN_CHARFOUND_P(ret)) { + ret = ONIGENC_MBCLEN_CHARFOUND_LEN(ret); + if (p + ret > e) ret = (int)(e - p); // just for case + return ret; + } + else if (ONIGENC_MBCLEN_NEEDMORE_P(ret)) { + return (int)(e - p); + } + return p < e ? 1 : 0; +} + +extern int onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc) { int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc, p, e); |