in reply to Re: Unicode to HTML code &#....;
in thread Unicode to HTML code &#....;
As you can see, this also swaps the replacement character with a space should there be one.use Encode qw(decode); sub unicode_decode { my $string = decode('utf8', shift, 0); $string =~ tr/\x{FFFD}/\x20/; $string =~ s/([^a-zA-Z0-9\_\+\-\.])/'&#'.unpack('U0U*',$1).';'/eg; return($string); }
|
|---|