PerlMonks seems to send pages in ISO-8859-1 encoding, which is giving me some unexpected trouble. To fix it, I've decided to use Encode to translate data to UTF-8 as soon as I download it. However, Perl is laughing at my attempts (the string is "Ámbito" in ISO-8859-1 and UTF-8 encodings):
$ perl -MEncode -e '$_="\xc3\x81mbito"; print $_, encode "iso-8859-1", + $_' | xxd 0000000: c381 6d62 6974 6fc3 816d 6269 746f ..mbito..mbito $ perl -MEncode -e '$_="\xc3\x81mbito"; print $_, decode "iso-8859-1", + $_' | xxd 0000000: c381 6d62 6974 6fc3 816d 6269 746f ..mbito..mbito $ perl -MEncode -e '$_="\xc1mbito"; print $_, encode "iso-8859-1", + $_' | xxd 0000000: c16d 6269 746f c16d 6269 746f .mbito.mbito $ perl -MEncode -e '$_="\xc1mbito"; print $_, decode "iso-8859-1", + $_' | xxd 0000000: c16d 6269 746f c16d 6269 746f .mbito.mbito
Most probably, PEBKAC but I don't see the "P". It isn't late enough (2:00 am) for this to be a silly thing :). I've "resolved" it using from_to but I don't have the feeling that this is the right way.
Update: No echo | perl needed. Changed examples accordingly. Clarified the meaning of the string literal. Updated PEBKAC link to use [jargon://].
--
David Serrano
In reply to Encode: unable to change encoding of strings by Hue-Bond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |