if (SvREADONLY(sv))
Perl_croak(aTHX_ PL_no_modify);
}
+
+ if (PL_encoding && !SvUTF8(sv)) {
+ /* like in do_chomp(), utf8-ize the sv as a side-effect
+ * if we're using encoding. */
+ sv_recode_to_utf8(sv, PL_encoding);
+ }
+
s = SvPV(sv, len);
if (len && !SvPOK(sv))
s = SvPV_force(sv, len);
}
else if (SvOK(sv) || SvTYPE(sv) > SVt_PVMG) {
dc = SvPV_force_nomg_nolen(sv);
- if (SvCUR(sv) < (STRLEN)len) {
+ if (SvLEN(sv) < (STRLEN)(len + 1)) {
dc = SvGROW(sv, (STRLEN)(len + 1));
(void)memzero(dc + SvCUR(sv), len - SvCUR(sv) + 1);
}
case OP_BIT_AND:
while (len--)
*dc++ = *lc++ & *rc++;
+ *dc = '\0';
break;
case OP_BIT_XOR:
while (len--)