Skip to content

Instantly share code, notes, and snippets.

@iliajie
Last active February 10, 2020 22:17
Show Gist options
  • Save iliajie/8cfeeb345b9513429798d1223d8f21bb to your computer and use it in GitHub Desktop.
Save iliajie/8cfeeb345b9513429798d1223d8f21bb to your computer and use it in GitHub Desktop.
Convert &#... to UTF-8 representatives
use Encode qw/encode decode/;
use HTML::Entities;
my $string = "Darf Kategorisierung verändern?";
$string = decode("big5", $string); # big5 to internal utf8 -> utf8::is_utf8($string) is true
decode_entities($string); # decode HTML entities
$string = encode('utf8', $string); # internal utf8 to raw bytes, utf8::is_utf8($string) is false
say $string; # Darf Kategorisierung verändern?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment