diff options
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c index eed384fb0d..fc0aa3b945 100644 --- a/encoding.c +++ b/encoding.c @@ -217,6 +217,26 @@ rb_enc_strlen(const char *p, const char *e, rb_encoding *enc) } int +rb_enc_mbclen(const char *p, rb_encoding *enc) +{ + int n = ONIGENC_MBC_ENC_LEN(enc, (UChar*)p); + if (n == 0) { + rb_raise(rb_eArgError, "invalid mbstring sequence"); + } + return n; +} + +int +rb_enc_codelen(int c, rb_encoding *enc) +{ + int n = ONIGENC_CODE_TO_MBCLEN(enc,c); + if (n == 0) { + rb_raise(rb_eArgError, "invalid mbstring sequence"); + } + return n; +} + +int rb_enc_toupper(int c, rb_encoding *enc) { return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_UPPER_CASE(c):(c)); |