use Capture::Tiny 'capture'; binmode(*STDOUT, ':utf8'); my $out = capture { print "Hi! \x{263a}\n"; system($^X, '-e', 'print "Hi! \x{263a}\n"'); };