diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-06 09:28:26 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-06 09:28:26 +0000 |
commit | 608bf50b05d1b2e8544d3c109aff74d961505f1d (patch) | |
tree | 161d7248925c7bd2c99d3ed6a341e81ba76b40c4 /encoding.c | |
parent | 40e44f99511431da05eff9402e76583a37011943 (diff) | |
download | ruby-608bf50b05d1b2e8544d3c109aff74d961505f1d.tar.gz ruby-608bf50b05d1b2e8544d3c109aff74d961505f1d.tar.xz ruby-608bf50b05d1b2e8544d3c109aff74d961505f1d.zip |
* encoding.c (rb_enc_precise_mbclen): new function for mbclen with
validation.
* include/ruby/encoding.h (rb_enc_precise_mbclen): declared.
(MBCLEN_CHARFOUND): new macro.
(MBCLEN_INVALID): new macro.
(MBCLEN_NEEDMORE): new macro.
* include/ruby/oniguruma.h (OnigEncodingTypeST): replace mbc_enc_len
by precise_mbc_enc_len.
(ONIGENC_PRECISE_MBC_ENC_LEN): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_INVALID): new macro.
(ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE): new macro.
(ONIGENC_MBCLEN_CHARFOUND): new macro.
(ONIGENC_MBCLEN_INVALID): new macro.
(ONIGENC_MBCLEN_NEEDMORE): new macro.
(ONIGENC_MBC_ENC_LEN): use ONIGENC_PRECISE_MBC_ENC_LEN.
* enc/euc_jp.c: validation implemented.
* enc/sjis.c: ditto.
* enc/utf8.c: ditto.
* string.c (rb_str_inspect): use rb_enc_precise_mbclen for invalid
encoding.
(rb_str_valid_encoding_p): new method String#valid_encoding?.
* io.c (rb_io_getc): use rb_enc_precise_mbclen.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c index ec7405f96..53ceac851 100644 --- a/encoding.c +++ b/encoding.c @@ -495,6 +495,12 @@ rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc) } int +rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) +{ + return ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); +} + +int rb_enc_codelen(int c, rb_encoding *enc) { int n = ONIGENC_CODE_TO_MBCLEN(enc,c); |