Re: No Gtk2 and no Perl utf8 bug (was: Re: Something-else-than-utf8 bug (was: Re: utf8 bug ?))



On Sun, Sep 05, 2004 at 10:07:45 +0200, Jörn Reder wrote:
1) If I insert 'use utf8;' in the first line, the error does NOT go
   away.
2) If I insert 'use utf8;' in the first line and comment out the
   Gtk2::Label->new, the error DOES go away.
3) If I insert 'use utf8;' and actualy use a non-ascii in $string, the
   problem DOES go away -- the label is still there!

The main difference for case 3) is that $string gets the utf8 flag set 
at compile time, because you assigned a literal utf8 value to $string. 
For the cases 1) and 2) 'use utf8' makes no difference, because your 
source code doesn't contain any utf8 characters, but plain ASCII - so 
$string has no utf8 flag set.

'use utf8;' tells the Perl compiler that your source code is written in
utf8 encoding. It doesn't change Perl's runtime behaviour, in particular
it's not needed to enable Unicode handling.

[...[

What are we doing here? We'r doing a substition regex on the global $_,
but the right side calls a sub which *modifies* $_. Is this expected to
work? No, this is really a bug in the script. Perl get's totatly 
confused about $_ and panics! ;)

We learn: don't struggle with globals! Use lexicals! ;)

Ok. So I want one thing. If I encode a script in unicode, I want all
string literals to behave the same and have the utf8 flag set. But some
of them happen not to contain any non-ascii characters. Now, how do I do
this?

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]