Ticket #160: mac-encoding.patch

File mac-encoding.patch, 950 bytes (added by ChrisDolan, 5 years ago)

proposed Mac solution

  • lib/Padre/Document.pm

     
    328328        } 
    329329    } else { # fail to get system default encoding 
    330330        warn "Could not find encoding of file '$file'. Defaulting to 'utf-8'. " 
    331             . "Please check it manually and report to the Padre development team."; 
     331            . "Please check it manually and report to the Padre development team." 
     332            if ! defined $system_default; 
    332333        $self->{encoding} = 'utf-8'; 
    333334    } 
    334335    $content = Encode::decode($self->{encoding}, $content); 
     
    374375    my $content  = $self->text_get; 
    375376    my $filename = $self->filename; 
    376377 
    377     if (open my $fh, ">:raw:encoding($self->{encoding})", $filename) { 
     378        my $encoding = $self->{encoding} || 'utf-8'; 
     379    if (open my $fh, ">:raw:encoding($encoding)", $filename) { 
    378380        print {$fh} $content; 
    379381    } else { 
    380382        return "Could not save: $!";