in reply to lost in utf8

By the way, you're double encoding (bad!)
my $line = encode("utf8",$lineo); open(TEK,">:utf8","temp.tex"); print TEK $line;
should be
my $line = encode("utf8",$lineo); open(TEK,">","temp.tex"); print TEK $line;
or
my $line = $lineo; open(TEK,">:utf8","temp.tex"); print TEK $line;

Replies are listed 'Best First'.
Re^2: lost in utf8
by oha (Friar) on Oct 23, 2009 at 20:03 UTC
    Doesn't the second block of code require a binmode() just for compatibility?

      binmode basically disables :crlf and :encoding.

      Since neither were used in the second snippet, we're talking about the default layers from the OS, from $ENV{PERLIO} or from use of the open pragma.

      While using binmode to remove any default :encoding may be smart, it may accidentally disable the :crlf layer. There's no indication that we want the :crlf status to be different, so it's better to use the last snippet if you're dealing with a text file.

      Now, if you're dealing with a binary file, you'd use binmode, and you'd use encode for the text bits. Any LF<->CRLF conversion will have to be handled manually.