in reply to How to test different encoding

Excactly, perl changes the LATIN1 back to unicode because the output stream STDOUT is utf8 in your case.

What you would have to do to see funny characters is to change the output stream with :encoding(...). On my machine

> perl -e 'binmode STDOUT, ":encoding(iso-8859-1)"; print STDOUT "Hüsk +er Dü\n";' Hüsker Dü > perl -e 'binmode STDOUT, ":encoding(utf8)"; print STDOUT "Hüsker Dü\ +n";' H**sker D**

I changed the nearly unprintable characters to **. Actually I was surprised to find out my linux is still using latin1 on the shell (or my reasoning is wrong).

You can find out some more with 'man perlunicode' and 'man encode'

Replies are listed 'Best First'.
Re^2: How to test different encoding
by ait (Hermit) on Sep 16, 2008 at 19:06 UTC
    Thanks!

    I found some good examples of encoding tests in XML::LibXML (the CPAN module that interfaces to Gnome's LibXML2). The file 19encoding.t does a whole bunch of tests similar to what I was trying to accomplish, and gives great ideas on how to use the encoding routines for testing.

    Best,
    Alejandro Imass
      Hi:
      I am interestring on the encoding problem, can you show me where the 19encoding.t file? I can't find this file in my system.
      My XML::LibXML is located in /usr/local/lib/perl/5.8.8/XML/, but I didn't find any file names 19encoding.t
      thx in advance:)
        You probably need to install the source of XML::LibXML, from CPAN or your distribution.