[Rt-commit] r4395 - HTTP-Server-Simple-Mason/lib/HTTP/Server/Simple

autrijus at bestpractical.com autrijus at bestpractical.com
Wed Jan 18 01:58:03 EST 2006


Author: autrijus
Date: Wed Jan 18 01:58:02 2006
New Revision: 4395

Modified:
   HTTP-Server-Simple-Mason/lib/HTTP/Server/Simple/Mason.pm

Log:
* :utf8 is much faster (and more reliable) than :encoding(utf8) in Perl 5.8.x.

Modified: HTTP-Server-Simple-Mason/lib/HTTP/Server/Simple/Mason.pm
==============================================================================
--- HTTP-Server-Simple-Mason/lib/HTTP/Server/Simple/Mason.pm	(original)
+++ HTTP-Server-Simple-Mason/lib/HTTP/Server/Simple/Mason.pm	Wed Jan 18 01:58:02 2006
@@ -141,7 +141,12 @@
 
             if ($r->content_type =~ /charset=([\w-]+)$/ ) {
                 my $enc = $1;
-                binmode *STDOUT, ":encoding($enc)";
+                if (lc($enc) =~ /^utf-?8$/) {
+                    binmode *STDOUT, ':utf8'; # faster than :encoding
+                }
+                else {
+                    binmode *STDOUT, ":encoding($enc)";
+                }
             }
             # We could perhaps install a new, faster out_method here that
             # wouldn't have to keep checking whether headers have been


More information about the Rt-commit mailing list