Erm. That's kind of hackish. I know that's my fault, because the header
stuff is coded so poorly here, but I just wanted to mention that if you
wanted to cleanup the header code (using a proper hash table under {header}
instead of a string), you're welcome ;)
If not, well, I'll gonna have to leave with the repentance of my bad coding
habits.
Many thanks for your work on po4a,
Mt.
On Fri, Aug 06, 2004 at 10:48:53PM +0000, Jordi Vilalta wrote:
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv314
Modified Files:
Po.pm
Log Message:
Added 2 new small functions: {g|s}et_charset(), that work with the po header
Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Po.pm 2 Aug 2004 09:35:39 -0000 1.16
+++ Po.pm 6 Aug 2004 22:48:51 -0000 1.17
@@ -265,7 +265,7 @@
=item gettextize()
This function produce one translated message catalog from two catalogs, an
-original an a translation. This process is described in po4a(7), section
+original and a translation. This process is described in po4a(7), section
I<Gettextization: how does it work?>.
=cut
@@ -873,6 +873,39 @@
return $msgid if ($self->{po}{$msgid}{'pos'} eq $num);
}
return undef;
+}
+
+=item get_charset()
+
+This returns the character set specified in the po header. If it hasn't been
+set, it will return "CHARSET".
+
+=cut
+
+sub get_charset() {
+ my $self=shift;
+ $self->{header} =~ /charset=(.*?)[\s\\]/;
+ return $1;
+}
+
+=item set_charset()
+
+This sets the character set of the po header to the value specified in its
+first argument. If you never call this function (and no file with an specified
+character set is read), the default value is left to "CHARSET". This value
+doesn't change the behavior of this module, it's just used to fill that field
+in the header, and to return it in get_charset().
+
+=cut
+
+sub set_charset() {
+ my $self=shift;
+
+ my ($newchar,$oldchar);
+ $newchar = shift;
+ $oldchar = $self->get_charset();
+
+ $self->{header} =~ s/$oldchar/$newchar/;
}
#----[ helper functions ]---------------------------------------------------
_______________________________________________
Po4a-devel mailing list
Po4a-devel(a)lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/po4a-devel
--
If you can't do it in ANSI C, it isn't worth doing.