summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index 10813a7316..5f3eeae4fe 100644
--- a/mg.c
+++ b/mg.c
@@ -3367,6 +3367,16 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
else sv_setiv(mg->mg_obj, (IV)PerlProc_getpid());
break;
case '0':
+ if (!sv_utf8_downgrade(sv, /* fail_ok */ TRUE)) {
+
+ /* Since we are going to set the string's UTF8-encoded form
+ as the process name we should update $0 itself to contain
+ that same (UTF8-encoded) value. */
+ sv_utf8_encode(GvSV(mg->mg_obj));
+
+ Perl_ck_warner_d(aTHX_ packWARN(WARN_UTF8), "Wide character in %s", "$0");
+ }
+
LOCK_DOLLARZERO_MUTEX;
S_set_dollarzero(aTHX_ sv);
UNLOCK_DOLLARZERO_MUTEX;