aboutsummaryrefslogtreecommitdiffstats
path: root/transcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/transcode.c b/transcode.c
index 386942689a..0182a205c2 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2672,6 +2672,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
rb_encoding *senc, *denc;
const char *sname, *dname;
int dencidx;
+ int explicitly_invalid_replace = TRUE;
rb_check_arity(argc, 0, 2);
@@ -2681,6 +2682,9 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
if (!ecflags) return -1;
arg1 = rb_obj_encoding(str);
}
+ if (!(ecflags & ECONV_INVALID_MASK)) {
+ explicitly_invalid_replace = FALSE;
+ }
ecflags |= ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE;
}
else {
@@ -2694,7 +2698,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
ECONV_XML_ATTR_CONTENT_DECORATOR|
ECONV_XML_ATTR_QUOTE_DECORATOR)) == 0) {
if (senc && senc == denc) {
- if (ecflags & ECONV_INVALID_MASK) {
+ if ((ecflags & ECONV_INVALID_MASK) && explicitly_invalid_replace) {
VALUE rep = Qnil;
if (!NIL_P(ecopts)) {
rep = rb_hash_aref(ecopts, sym_replace);