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

Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)' failed." [5.12.1]

Thread Previous | Thread Next
From:
Gisle Aas
Date:
November 26, 2010 14:12
Subject:
Re: "perl: utf8.c:1997: Perl_swash_fetch: Assertion `klen <= sizeof(PL_last_swash_key)' failed." [5.12.1]
Message ID:
B0995DB4-6161-4A09-8A85-56CA8A9CFEBF@activestate.com
On Nov 26, 2010, at 22:03 , Reverend Chip wrote:

> Hm, would malformed utf8 on stdin come in without validation?  I never
> do utf8 I/O so I don't know.

If you use the ':utf8' IO layer then perl just slaps the SvUTF8-flag on whatever it receives.

You need the ':encoding(utf8)' flag for perl to be more careful in its decoding.

Demo:

$ perl -le 'print "\xA0"'  |
   perl -e 'binmode(STDIN, ":utf8"); use Devel::Peek; Dump(<STDIN>)'
SV = PV(0x801838) at 0x8039e0
  REFCNT = 1
  FLAGS = (TEMP,POK,pPOK,UTF8)
  PV = 0x207f20 "\240\n"\0 [UTF8 "\x{280}\n"]
  CUR = 2
  LEN = 3

Regard,
Gisle


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