[Padre-dev] utf8 patch

Fayland Lam fayland at gmail.com
Sun Nov 2 19:49:28 PST 2008


Index: lib/Padre/Document.pm
===================================================================
--- lib/Padre/Document.pm	(revision 673)
+++ lib/Padre/Document.pm	(working copy)
@@ -272,6 +272,7 @@
 		warn $@;
 		return;
 	}
+	utf8::decode($content);
 	$self->{_timestamp} = $self->time_on_file;
 	my $current_type = Padre::Util::newline_type($content);
 	if ($current_type eq 'None') {

it fixes the read problem I think.
padre crashes when I open a utf8 file without this line.
so we should add this line.


@@ -314,6 +315,9 @@
 	my $filename     = $self->filename;
     #my $newline_type = $self->get_newline_type;
 
+	if ( $content && utf8::is_utf8($content) ){
+        utf8::encode( $content );
+    }
 	eval {
 		File::Slurp::write_file($filename, {binmode => ':raw'}, $content);
 	};


well, it's not so good.
it would change file encode indeed. so ignore it is another choice.

Thanks.

-- 
Fayland Lam // http://www.fayland.org/ 
Foorum based on Catalyst // http://www.foorumbbs.com/ 



More information about the Padre-dev mailing list