#!/usr/bin/perl use Encode; my $s = "This line contains 0xC30x86n exotic character."; $s =~ s/0x([\da-fA-F]{2})/chr(hex($1))/ge; my $u = decode('UTF-8', $s);