summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/transcode.c b/transcode.c
index b01d4a1f086..1997e310c33 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2457,7 +2457,8 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
if (argc == 0) {
arg1 = rb_enc_default_internal();
if (NIL_P(arg1)) {
- return -1;
+ if (!ecflags) return -1;
+ arg1 = rb_obj_encoding(str);
}
ecflags |= ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE;
}