For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > June 2006 > Re: BUG in encoding package requires spac









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: BUG in encoding package requires spac
Mumia W.

2006-06-04, 6:59 pm

Dr.Ruud wrote:
> Mumia W. schreef:
>
> no utf8 ;
>
> Insert "no utf8;" before the "use encoding ..." line.
>


It works!

And I think I see why (from man utf8):

> Note that if you have bytes with the eighth bit on in your script (for
> example embedded Latin-1 in your string literals), "use utf8" will be
> unhappy since the bytes are most probably not well-formed UTF-8. If
> you want to have such bytes and use utf8, you can disable utf8 until
> the end the block (or file, if at top level) by "no utf8;".


Thanks for the utf8 idea. So it seems that we have a lot of ways to
solve this problem: (1) put a space between the variable and the special
character, (2) put the variable name in curly braces, (3) put a
backslash before the special character, (4) specify 'no utf8', and (5)
go ahead and convert the file to utf8 and 'use utf8':

#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use encoding 'utf-8';

local $\ = "\n";
our $string = 'Something fun';
print "Reg: $string®";
print "B-Bar: $string¦";
print "Quoted: «$string»";
print "Yen: $string¥";
print "Euro: $string€";

our $exoネtic = 'ネニ _ њ シßぬ ヌ に _';
print "exoネtic = $exoネtic";

__END__


It seems that utf8 extends the core perl parser in some interesting ways.


harryfmudd [AT] comcast [DOT] net

2006-06-05, 7:58 am

Mumia W. wrote:
>
>
> Thanks for the utf8 idea. So it seems that we have a lot of ways to
> solve this problem: (1) put a space between the variable and the special
> character, (2) put the variable name in curly braces, (3) put a
> backslash before the special character, (4) specify 'no utf8', and (5)
> go ahead and convert the file to utf8 and 'use utf8':
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use utf8;
> use encoding 'utf-8';
>
> local $\ = "\n";
> our $string = 'Something fun';
> print "Reg: $string®";
> print "B-Bar: $string¦";
> print "Quoted: «$string»";
> print "Yen: $string¥";
> print "Euro: $string€";
>
> our $exoネtic = 'ネニ _ њ シßぬ ヌ に _';
> print "exoネtic = $exoネtic";
>
> __END__
>
>
> It seems that utf8 extends the core perl parser in some interesting ways.
>
>


And non-obvious. It looks now like the behaviour is a feature (i.e. is
documented). But it sure didn't pop out on my first pass through the
documentation. Thanks.

Tom Wyant
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com