develooper Front page | perl.unicode | Postings from July 2010

=?windows-1252?Q?Silence_=93Wide_character=94_warning_globally_o?==?windows-1252?Q?ne_time?=

Thread Next
From:
Dan Muey
Date:
July 29, 2010 14:59
Subject:
=?windows-1252?Q?Silence_=93Wide_character=94_warning_globally_o?==?windows-1252?Q?ne_time?=
Message ID:
9F4D44F0-3037-42EA-876A-E470377C13D7@cpanel.net
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
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About