#!/usr/bin/perl use strict; use warnings; use Encode; use utf8; binmode STDOUT, ":utf8"; my $a = "情報時代"; $a =~ s/&#x([0-9A-F]{4});/decode('UCS2', pack('H*', $1))/ge; print "$a\n";
正規表現の場合は chr と hex。my $a = "情報時代"; use HTML::Entities; print HTML::Entities::decode($a), "\n";
dankogai さんの記事もご参照ください。my $a = "情報時代"; $a =~ s/&#x([0-9A-F]{4});/chr(hex($1))/ge; print "$a\n";