Skip to content

Instantly share code, notes, and snippets.

@yusukebe yusukebe/tradsimp.pl
Last active Mar 2, 2020

Embed
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
You can’t perform that action at this time.