Rodster001 has asked for the wisdom of the Perl Monks concerning the following question:
I've tried something like:print Dumper $text; $VAR1 = { 'string' => "Text\x{daed}", }; print $text->{'string'}; 'Unicode surrogate U+DAED is illegal in UTF-8 at line 5.
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".local $SIG{__WARN__} = sub { print "WARNING!\n"; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unicode surrogate is illegal in UTF-8
by choroba (Cardinal) on Aug 03, 2015 at 18:40 UTC | |
by Rodster001 (Pilgrim) on Aug 03, 2015 at 19:11 UTC | |
by Rodster001 (Pilgrim) on Aug 03, 2015 at 20:05 UTC | |
by Rodster001 (Pilgrim) on Aug 03, 2015 at 20:33 UTC | |
by choroba (Cardinal) on Aug 03, 2015 at 21:23 UTC | |
by afoken (Chancellor) on Aug 05, 2015 at 03:33 UTC |