perl-unicode

Silence “Wide character” warning globally one time

2010-07-29 16:59:41
Hello all,

I've a situation where a large code base will be outputting "byte strings" and 
"unicode strings" from a number of sources.

I essentially need to do 
     no warnings "utf8";
but I need to do it one time and globally instead of limiting to a package or 
some scope.

Is there a way to have the same effect as "no warnings 'utf8';" universally 
without the need to do it in every package and scope?

Here is a simplified version of the problem:

[ -- Problem: Unicode string gives warning -- ]

    perl -le 'print "Think before you code™ (bytes string)";print "Hello 
\x{201C}World\x{201D} (Unicode String)";'

adding either of these doesn't change the effect:

   $ENV{LC_CTYPE} = "UTF-8";
   ${^WIDE_SYSTEM_CALLS} = 1;

[ -- Partial solution but new problem: Warning goes away but byte string has 
garbled trademark character -- ]

    perl -le 'binmode STDOUT, "utf8";print "Think before you code™ (bytes 
string)";print "Hello \x{201C}World\x{201D} (Unicode String)";'

    PERL_UNICODE=6 perl -le 'print "Think before you code™ (bytes 
string)";print "Hello \x{201C}World\x{201D} (Unicode String)";'

[ -- this  has no warning and no garbled characters but it is impractical to 
impossible to do the pragma everywhere ti might be necessary  -- ]

    perl -le 'no warnings "utf8";print "Think before you code™ (bytes 
string)";print "Hello \x{201C}World\x{201D} (Unicode String)";'

[ -- ideal solution -- ]

Since we use our localization module everywhere that will have \x{} notationo 
I'd like to do whatever needs done in its begin block.

Is there any super voo doo that can be done?

Thanks in advance for any input!

--
Dan - cPanel.net