in reply to Re^2: How to avoid decoding string to utf-8.
in thread How to avoid decoding string to utf-8.
First string gets double decoded
You are mistaken. utf8::decode won't do anything if the string is already decoded (except in the very specific and unusual cases I mentioned in my earlier post).
$ perl -CS -e' my $s = "\xC3\xA0\xC3\xA1\xC3\xA2\xC3\xA4"; printf("Before first decode: %1\$vX [%1\$s]\n", $s); utf8::decode($s) or warn("First decode failed.\n"); printf("After first decode: %1\$vX [%1\$s]\n", $s); utf8::decode($s) or warn("Second decode failed.\n"); printf("After second decode: %1\$vX [%1\$s]\n", $s); ' Before first decode: C3.A0.C3.A1.C3.A2.C3.A4 [à áâä] After first decode: E0.E1.E2.E4 [àáâä] Second decode failed. After second decode: E0.E1.E2.E4 [àáâä]
|
|---|