set binmode encoding on STDERR when setting Encoding in config
Mark Ellis [Thu, 8 May 2014 12:43:25 +0000 (13:43 +0100)]
Changes
lib/Catalyst/Plugin/Unicode/Encoding.pm

diff --git a/Changes b/Changes
index fa58fa2..6175a9c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+  - Set encoding on STDERR when encoding is set in config
   - Fix spelling, grammar and structural errors in POD
   - Remove redundant ->setup call in t/head_middleware.t RT#95361
   - Fix test failures when running under CATALYST_DEBUG. RT#95358
index 7c61530..022efd2 100644 (file)
@@ -23,6 +23,10 @@ sub encoding {
         if (my $wanted = shift)  {
             $encoding = Encode::find_encoding($wanted)
               or Carp::croak( qq/Unknown encoding '$wanted'/ );
+            binmode(STDERR, ':encoding(' . $encoding->name . ')');
+        }
+        else {
+            binmode(STDERR);
         }
 
         $encoding = ref $c