summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-22 16:53:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-22 16:53:50 +0000
commit38c7a687e174e5fc7761cf05f71003ad6b728320 (patch)
tree43f41183c4bbe3684284dce2d442833f1d5aa237 /string.c
parentb6807f8356c670bb3668378a796f45e3e32ba007 (diff)
* string.c (rb_str_conv_enc_opts): new function to convert with
specifying ecflags and ecopts. * ext/zlib/zlib.c (gzfile_newstr): specify ecflags and ecopts for conversion using above function. * ext/zlib/zlib.c (gzfile_newstr): use own rb_econv_t for dummy encoding to handling stateful encoding (e.g. iso-2022-jp). [ruby-dev:36857] * ext/zlib/zlib.c (gzfile_getc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/string.c b/string.c
index 16df6021d7..fae5978325 100644
--- a/string.c
+++ b/string.c
@@ -473,7 +473,7 @@ RUBY_ALIAS_FUNCTION(rb_tainted_str_new2(const char *ptr), rb_tainted_str_new_cst
#define rb_tainted_str_new2 rb_tainted_str_new_cstr
VALUE
-rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
+rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
{
rb_econv_t *ec;
rb_econv_result_t ret;
@@ -497,7 +497,7 @@ rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
newstr = rb_str_new(0, len);
retry:
- ec = rb_econv_open_opts(from->name, to->name, 0, Qnil);
+ ec = rb_econv_open_opts(from->name, to->name, ecflags, ecopts);
if (!ec) return str;
sp = (unsigned char*)RSTRING_PTR(str);
@@ -525,6 +525,12 @@ rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
}
VALUE
+rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
+{
+ return rb_str_conv_enc_opts(str, from, to, 0, Qnil);
+}
+
+VALUE
rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
{
VALUE str;