develooper Front page | perl.perl5.porters | Postings from March 2007

Re: the utf8 flag (was Re: [perl #41527] decode_utf8 sets utf8 flag on plain ascii strings)

Thread Previous | Thread Next
From:
Juerd Waalboer
Date:
March 30, 2007 18:53
Subject:
Re: the utf8 flag (was Re: [perl #41527] decode_utf8 sets utf8 flag on plain ascii strings)
Message ID:
20070331015325.GT31277@c4.convolution.nl
Juerd Waalboer skribis 2007-03-30 21:53 (+0200):
> Personally, I think that unpack with a byte-specific signature should
> die, or at least warn, when its operand has the UTF8 flag set.

I've since this post changed my mind, and think it should only warn if
there are wide characters after attempting to downgrade first. Just like
the existing "wide character in %s" warning.

juerd@lanova:~$ perl -wle'$a = "foo\x{ff}"; utf8::upgrade($a); print $a' | hexdump -C
00000000  66 6f 6f ff 0a                                    |foo..|
00000005
juerd@lanova:~$ perl -wle'$a = "foo\x{20ac}"; utf8::upgrade($a); print $a' | hexdump -C
Wide character in print at -e line 1.
00000000  66 6f 6f e2 82 ac 0a                              |foo....|
00000007
-- 
korajn salutojn,

  juerd waalboer:  perl hacker  <juerd@juerd.nl>  <http://juerd.nl/sig>
  convolution:     ict solutions and consultancy <sales@convolution.nl>

Ik vertrouw stemcomputers niet.
Zie <http://www.wijvertrouwenstemcomputersniet.nl/>.

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