mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
b36cbe285d
commit
241ad8877d
3 changed files with 19 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
|||
Sat Jul 20 12:13:37 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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.
|
||||
|
||||
Fri Jul 19 21:59:12 2013 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* gc.c: declare type_name() at the beggining of file.
|
||||
|
|
|
@ -996,6 +996,13 @@ rb_enc_codelen(int c, rb_encoding *enc)
|
|||
return n;
|
||||
}
|
||||
|
||||
#undef rb_enc_code_to_mbclen
|
||||
int
|
||||
rb_enc_code_to_mbclen(int code, rb_encoding *enc)
|
||||
{
|
||||
return ONIGENC_CODE_TO_MBCLEN(enc, code);
|
||||
}
|
||||
|
||||
int
|
||||
rb_enc_toupper(int c, rb_encoding *enc)
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue