perl-unicode

[Encode] encoding.pm made slightly more intuitive

2002-05-06 03:21:20
On Monday, May 6, 2002, at 06:57 , Dan Kogai wrote:
On Monday, May 6, 2002, at 05:16 , Tatsuhiko Miyagawa wrote:
panic happens while hacking with encoding pragma.

It seems "use encoding" is still in effect after you 'use EncBar'. Simply commenting out 'use encoding 'euc-jp'' in encoding-test.pl makes the program work as expected.

Dan

The following patch will make encoding.pm slightly more intuitive -- that is, by 'no encoding' after the module that uses it you can make the module behave more intuitively. I need to document this somewhere....

> cat EncBar.pm test.pl
package EncBar;
use encoding 'euc-jp';
sub foo { "\xa4\xdb" }
no encoding;
1;
use strict;
require 5.7.3;

use EncBar;

use Devel::Peek;
my $foo = EncBar::foo;
Dump $foo;
use encoding 'euc-jp';
print $foo, "\n";

Dan the Encode Maintainer

diff -du -r1.34 encoding.pm
--- encoding.pm 2002/04/27 19:36:18     1.34
+++ encoding.pm 2002/05/06 09:51:28
@@ -75,8 +75,13 @@
 sub unimport{
     no warnings;
     undef ${^ENCODING};
-    binmode(STDIN);
-    binmode(STDOUT);
+    if ($HAS_PERLIO){
+       binmode(STDIN,  ":raw");
+       binmode(STDOUT, ":raw");
+    }else{
+       binmode(STDIN);
+       binmode(STDOUT);
+    }
     if ($INC{"Filter/Util/Call.pm"}){
        eval { filter_del() };
     }

<Prev in Thread] Current Thread [Next in Thread>