perl-unicode

Layers Issue in SVN::Notify

2006-07-10 12:25:33
Greetings fellow Perlers,

I've had some complaints for a while now about non-ASCII characters not properly showing up in emails sent by my SVN::Notify module. Last week Éric Cholet figured out how to get it to work: He simply set the LANG environment variable to fr_FR.ISO8859-1.

So the problem is the LANG environment variable. Setting it to 'C' in a BEGIN block doesn't work, either. But my sense is that it shouldn't make any difference what the environment is set to if I'm setting the IO layer on the file handle. Here is the code for creating the handle in SVN::Notify:

sub _pipe {
    my ($self, $mode) = (shift, shift);
    $self->_dbpnt( q{Piping execution of "} . join(q{" "}, @_) . q{"})
      if $self->{verbose};
    # Safer version of backtick (see perlipc(1)).
    local *PIPE;
    if (WIN32) {
        my $cmd = $mode eq '-|'
            ? q{"}  . join(q{" "}, @_) . q{"|}
            : q{|"} . join(q{" "}, @_) . q{"};
        open PIPE, $cmd or die "Cannot fork: $!\n";
        binmode PIPE, ":$self->{io_layer}" if PERL58;
        return *PIPE;
    }

    my $pid = open PIPE, $mode;
    die "Cannot fork: $!\n" unless defined $pid;

    if ($pid) {
# Parent process. Set the encoing layer and return the file handle.
        binmode PIPE, ":$self->{io_layer}" if PERL58;
        return *PIPE;
    } else {
        # Child process. Execute the commands.
        exec @_ or die "Cannot exec $_[0]: $!\n";
        # Not reached.
    }
}

I'm using binmode to set the IO layer on the pipe both for reading and writing pipes, so I'd expect it to do the right thing vis-a-vis the localization without regard to the LANG environment variable (Éric had the io_layer attribute set to 'raw'). But obviously I'm wrong. Is there something I'm missing about when and/or where the IO layer should be set? Anyone run into something like this before?

Thanks for the help.

Best,

David

<Prev in Thread] Current Thread [Next in Thread>