Method: Iconv#initialize
- Defined in:
- ext/iconv/iconv.c
#new(to, from, [options]) ⇒ Object
Creates new code converter from a coding-system designated with from to another one designated with to.
Parameters
to-
encoding name for destination
from-
encoding name for source
options-
options for converter
Exceptions
- TypeError
-
if
toorfromaren’t String - InvalidEncoding
-
if designated converter couldn’t find out
- SystemCallError
-
if
iconv_open(3)fails
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
# File 'ext/iconv/iconv.c', line 721 static VALUE iconv_initialize(int argc, VALUE *argv, VALUE self) { VALUE to, from, ; struct rb_iconv_opt_t opt; int idx; rb_scan_args(argc, argv, "21", &to, &from, &); get_iconv_opt(&opt, ); iconv_free(check_iconv(self)); DATA_PTR(self) = NULL; DATA_PTR(self) = (void *)ICONV2VALUE(iconv_create(to, from, &opt, &idx)); #ifdef HAVE_RUBY_ENCODING_H if (idx >= 0) ENCODING_SET(self, idx); #endif return self; } |