diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | include/ruby/encoding.h | 1 | ||||
-rw-r--r-- | transcode.c | 14 |
3 files changed, 20 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Fri Sep 26 11:05:41 2008 NAKAMURA Usaku <usa@ruby-lang.org> + + * transcode.c, include/ruby/encoding.c (rb_transcode_convertible): + new function. checking the existance of converter. + Fri Sep 26 10:35:50 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * variable.c (global_variable, struct trace_var): made function diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 2c7f105ec3..b6ac57418c 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -209,6 +209,7 @@ typedef enum { typedef struct rb_econv_t rb_econv_t; VALUE rb_str_transcode(VALUE str, VALUE to, int ecflags, VALUE ecopts); +int rb_transcode_convertible(const char* from_encoding, const char* to_encoding); int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts); diff --git a/transcode.c b/transcode.c index 26c57d039d..1f0909cd3f 100644 --- a/transcode.c +++ b/transcode.c @@ -2839,6 +2839,20 @@ econv_s_search_convpath(int argc, VALUE *argv, VALUE klass) return convpath; } +/* + * check the existance of converter. + * returns the count of the converting paths. + * result: >=0:success -1:failure + */ +int +rb_transcode_convertible(const char* from_encoding, const char* to_encoding) +{ + VALUE convpath = Qnil; + transcode_search_path(from_encoding, to_encoding, search_convpath_i, + &convpath); + return RTEST(convpath); +} + struct rb_econv_init_by_convpath_t { rb_econv_t *ec; int index; |