From cf36df97fb74f60b321fe5617b3805078393c028 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 23 Dec 2007 14:06:00 +0000 Subject: * encoding.c (rb_enc_codepoint): implemented to raise invalid encoding. * include/ruby/encoding.h (rb_enc_codepoint): macro is replaced as a declaration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- encoding.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'encoding.c') 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) { -- cgit v1.2.3