I have in a ANSI file perl script the following code.
use strict;
use warnings;
use Encode;
sub UnicodeDecHashNumsToText($)
{
use open qw/:std :encoding(UTF-8)/; # Tell perl standard output etc. use utf-8
my( $lText ) = @_;
print "Orig Text = '$lText'n";
$lText =~ s/^#(d+)/chr($1)/e; # e treats the replacement as code, not text
print "Returning: (".length($lText).")'$lText'n";
return $lText;
}
# Comparing
# The 'got' value is obtained reading a normal file.
my $got = UnicodeDecHashNumsToText( "#8364" );
# The 'expected' value is read through a select statement
# from a database in locale: en_US.819
my $expected = "€";
print "'$got' vs '$expected' n";
if( $got ne $expected ) { print "FAILEDn"; } else { print "SUCCESSn"; }
Output:
Orig Text = '#8364'
Returning: (1)'€'
'€' vs ''
FAILED
The compare fails.
What changes or additions needs to be done for the compare to be ok?
Please help, many thanks in advance.