Subject: | strange behaviour in from_to with UTF-8 encoding and Latin1 range |
use Devel::Peek;
use Encode qw/from_to/;
my $a = "\xC2\xB5";
die unless from_to($a, 'utf-8', 'cp1251');
Dump $a;
__END__
SV = PV(0x20e2c20) at 0x21104d8
REFCNT = 1
FLAGS = (PADMY,POK,pPOK)
PV = 0x20fd0a0 "\265"\0
CUR = 1
LEN = 16
\xC2\xB2 is Latin1 character (Unicode 0xB5) in UTF-8 encoding. It does not map to CP1251 (Windows 1251)
but from_to will return byte 0xB5 for it (i.e. character with code 0xB5 in CP1251).
why so? it should instead replace it with replacement character.
p.s.
same behaviour if $check parameter is true.