summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 03:13:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 03:13:40 +0000
commit241ad8877d7a085a4ad7427b21c1eaee6242d6e7 (patch)
tree19ecd2809d3e18687d5565918613a3e19a3b35c3 /include
parentb36cbe285dd82a957c56aa7cb2e116658d4374af (diff)
encoding.c: add rb_enc_code_to_mbclen
* encoding.c (rb_enc_code_to_mbclen): add new function which returns mbclen from codepoint like as rb_enc_codelen() but 0 for invalid char. * include/ruby/encoding.h (rb_enc_code_to_mbclen): declaration and shortcut macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/encoding.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 2cd44eafe1..62e9b6642d 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -147,6 +147,9 @@ unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
/* -> codelen>0 or raise exception */
int rb_enc_codelen(int code, rb_encoding *enc);
+/* -> 0 for invalid codepoint */
+int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
+#define rb_enc_code_to_mbclen(c, enc) ONIGENC_CODE_TO_MBCLEN((enc), (c));
/* code,ptr,encoding -> write buf */
#define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC((enc),(c),(UChar*)(buf))