summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/transcode.c b/transcode.c
index 5e14a358b8..1ba30c8256 100644
--- a/transcode.c
+++ b/transcode.c
@@ -1327,16 +1327,15 @@ rb_econv_stateless_encoding(const char *stateful_enc)
}
VALUE
-rb_econv_string(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int flags)
+rb_econv_substr_append(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int flags)
{
unsigned const char *ss, *sp, *se;
unsigned char *ds, *dp, *de;
rb_econv_result_t res;
int max_output;
- if (NIL_P(dst)) {
+ if (NIL_P(dst))
dst = rb_str_buf_new(len);
- }
if (ec->last_tc)
max_output = ec->last_tc->transcoder->max_output;
@@ -1367,6 +1366,24 @@ rb_econv_string(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int fl
return dst;
}
+VALUE
+rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags)
+{
+ return rb_econv_substr_append(ec, src, 0, RSTRING_LEN(src), dst, flags);
+}
+
+VALUE
+rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
+{
+ return rb_econv_substr_append(ec, src, byteoff, bytesize, Qnil, flags);
+}
+
+VALUE
+rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
+{
+ return rb_econv_substr_append(ec, src, 0, RSTRING_LEN(src), Qnil, flags);
+}
+
void
rb_econv_binmode(rb_econv_t *ec)
{