aboutsummaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c
index 52f311f1ca..c926dac142 100644
--- a/encoding.c
+++ b/encoding.c
@@ -661,6 +661,15 @@ rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
return c;
}
+int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
+{
+ int r = rb_enc_precise_mbclen(p, e, enc);
+ if (MBCLEN_CHARFOUND(r))
+ return ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e);
+ else
+ rb_raise(rb_eArgError, "invalid mbstring sequence");
+}
+
int
rb_enc_codelen(int c, rb_encoding *enc)
{