[Po4a-devel][CVS] po4a/lib/Locale/Po4a Xml.pm,1.13,1.14

Jordi Vilalta po4a-devel@lists.alioth.debian.org
Sun, 08 Aug 2004 18:44:59 +0000


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv27778

Modified Files:
	Xml.pm 
Log Message:
Now the Xml module detects the input document's encoding and substitutes it
by the output document's one


Index: Xml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Xml.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Xml.pm	8 Aug 2004 06:27:51 -0000	1.13
+++ Xml.pm	8 Aug 2004 18:44:56 -0000	1.14
@@ -368,15 +368,17 @@
 }
 
 sub tag_trans_xmlhead {
-#TODO
 	my ($self,@tag)=@_;
-my $tag = $self->join_lines(@tag);
-	$tag =~ /^(\S*)(\s*)(.*)/s;
-	my ($name,$spaces,$attr)=($1,$2,$3);
 
-	#We get the file encoding
-	#my $enc=$self->attribute($attr,"encoding");
-	#print $enc."\n";
+	# We don't have to translate anything from here: throw away references
+	my $tag = $self->join_lines(@tag);
+	$tag =~ /encoding=(("|')|)(.*?)(\s|\2)/s;
+	my $in_charset=$3;
+	my $out_charset=$self->detected_charset($in_charset);
+
+	$tag =~ s/$in_charset/$out_charset/
+		unless !defined($out_charset) or $out_charset eq "";
+
 	return $tag;
 }