sub _checkit { my $txt = shift; use warnings FATAL => 'utf8'; 1 until eval { print "$txt\n"; 1; } or do { my ($charcode) = $@ =~ /U\+(\S+)/ or die $@; $txt =~ s/\x{$charcode}//g; 0; # Try again! }; return ($txt); }