Hi Monks,
I have some invalid utf-8. I want to catch the warning messages, and just un/redefine the string.
For example:
print Dumper $text;
$VAR1 = {
'string' => "Text\x{daed}",
};
print $text->{'string'};
'Unicode surrogate U+DAED is illegal in UTF-8 at line 5.
I've tried something like:
local $SIG{__WARN__} = sub {
print "WARNING!\n";
};
Which catches the warning, but I lose context. I want to detect the warning then just set $text->{'string'} = "bad utf-8 encoding" or better yet, remove the offending character (regex?) so I end up with $text->{string} = "Text".
Thanks for your help.