in reply to Removing Unsafe Characters

Removes all Unicode characters:

my $output = ''; while ($input =~ /(.)/sg) { my $ch = $1; my $ord = ord($ch); $output .= $ch if $ord >= 0xD800 && $ord <= 0xDFFF || $ord >= 0xFDD0 && $ord <= 0xFDEF || ($ord & 0xFFFF) == 0xFFFE || ($ord & 0xFFFF) == 0xFFFF || $ord >= 0x110000; }

:)

Replies are listed 'Best First'.
Re^2: Removing Unsafe Characters
by Praethen (Scribe) on Apr 28, 2009 at 20:56 UTC

    Thanks for the suggestion, though it took "This is a test message."

    and created... "isisaesmessage" ;)

      Oops! Added missing parens. I hate &'s precedence.