develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #80030] Matching upper ASCII characters from file in RE patterns

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
December 4, 2010 05:23
Subject:
Re: [perl #80030] Matching upper ASCII characters from file in RE patterns
Message ID:
20101204222234.EC79.CB027F2D@nifty.com

On Tue, 30 Nov 2010 21:26:20 -0500
Eric Brine <ikegami@adaelis.com> wrote:

> On Tue, Nov 30, 2010 at 4:57 PM, Jonathan Pool <perlbug-followup@perl.org>wrote:

>     print ('3. The NBS is ' . (/[\x7f-\x80]/ ? '' : 'NOT ') . 'matched by
> /[\7f-\x80]/' . "\n");
> 
> 
> > With "use encoding 'utf8'" (or with both pragmas), [...] patterns 4, 5, and
> > 6 fail instead of matching.
> >
> 
> I'm not sure if that's a bug, or if it's broken by design.
> 
> - Eric

This seems be able to be explained and perhaps not a bug.

According to POD of encoding.pm, 
(see http://search.cpan.org/~dankogai/Encode-2.40/encoding.pm )
"\xDF" under use encoding "iso 8859-7" is \x{3af} in Unicode
"\xA4\xA1" under use encoding "euc-jp" is  \x{3041} in Unicode

Then, under use encoding "utf8", U+00A0 in Unicode should be "\xC2\xA0".
Use of "\xA0" expecting U+00A0 is wrong.

The reason why /[\x7F-\x80]/ matches U+00A0 is that /[\x7F-\x{FFFD}]/
matches U+00A0 as \x80 is malform as utf8 and replaced with \x{FFFD}.

Regards,
SADAHIRO Tomoyuki


Thread Previous | 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