Skip to content

Instantly share code, notes, and snippets.



Last active Mar 2, 2020
What would you like to do?
use utf8;
use Unicode::Unihan;
use feature qw/say/;
binmode STDOUT, ":utf8";
my $original = "";
say $original; #
my $uh = Unicode::Unihan->new;
my $traditional = $uh->ZVariant($original);
$traditional = unescape($traditional);
say $traditional; #
my $simplified = $uh->SimplifiedVariant($traditional);
$simplified = unescape($simplified);
say $simplified; #
sub unescape {
my $char = shift;
$char =~ m!U\+([0-9a-fA-F]{4})!;
return chr(hex($1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment