]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex.pm
CGI::Ex 2.22
[chaz/p5-CGI-Ex] / lib / CGI / Ex.pm
index 6737649d3815b6f6d358091e2af8e9e4f31b8954..f8b666cdf06b42db89cb0a355b25ab88353cf6b5 100644 (file)
@@ -24,7 +24,7 @@ use vars qw($VERSION
 use base qw(Exporter);
 
 BEGIN {
-    $VERSION               = '2.14';
+    $VERSION               = '2.22';
     $PREFERRED_CGI_MODULE  ||= 'CGI';
     @EXPORT = ();
     @EXPORT_OK = qw(get_form
@@ -249,7 +249,7 @@ sub content_type { &print_content_type }
 #   print_content_type();
 #   print_content_type('text/plain);
 sub print_content_type {
-    my ($self, $type) = ($#_ >= 1) ? @_ : ref($_[0]) ? (shift, undef) : (undef, shift);
+    my ($self, $type, $charset) = (@_ && ref $_[0]) ? @_ : (undef, @_);
     $self = __PACKAGE__->new if ! $self;
 
     if ($type) {
@@ -257,6 +257,7 @@ sub print_content_type {
     } else {
         $type = 'text/html';
     }
+    $type .= "; charset=$charset" if $charset && $charset =~ m|^[\w\-\.\:\+]+$|;
 
     if (my $r = $self->apache_request) {
         return if $r->bytes_sent;
@@ -920,6 +921,14 @@ else already printed content-type).  Calling this sends the Content-type
 header.  Trying to print -E<gt>content_type is an error.  For clarity,
 the method -E<gt>print_content_type is available.
 
+    $cgix->print_content_type;
+
+    # OR
+    $cgix->print_content_type('text/html');
+
+    # OR
+    $cgix->print_content_type('text/html', 'utf-8');
+
 =item C<-E<gt>set_cookie>
 
 Arguments are the same as those to CGI->new->cookie({}).
@@ -1038,12 +1047,12 @@ See also L<CGI::Ex::Template>.
 
 See also L<CGI::Ex::Validate>.
 
-=head1 AUTHOR
-
-Paul Seamons
-
 =head1 LICENSE
 
 This module may be distributed under the same terms as Perl itself.
 
+=head1 AUTHOR
+
+Paul Seamons <perl at seamons dot com>
+
 =cut
This page took 0.023789 seconds and 4 git commands to generate.