UTF-8: print from a file of codes

From JmPm

Jump to: navigation, search
binmode(STDOUT, ":utf8"); # to silence: "Wide character in print "
$in = <DATA>;
$chr1=chr(hex ($in));
$string = "Hello $chr1 !\n";
print $string;

This program brings hexadecimal data from a file and prints it as a utf8 character (if it is one). The main problem here was to change a string such as '236a' which perl cannot know is a number, into a number,because of the lack of types in perl.

Personal tools