develooper Front page | perl.perl5.porters | Postings from January 2001

Not OK: perl v5.7.0 +DEVEL8342 substr() UTF8 with not UTF8

Thread Next
From:
Roca, Ignasi
Date:
January 10, 2001 09:10
Subject:
Not OK: perl v5.7.0 +DEVEL8342 substr() UTF8 with not UTF8
Message ID:
5930DC161690D2119667009027157547037E2EDF@madt009a.siemens.es
I have problems with substr() in an EBCDIC machine, but I'm affraid that
those problems occur also in ASCII machines.

Can anybody try following tests in ASCII machine to see the results ?

../perl -I../lib -MDevel::Peek -e '$x="\xF1\xF2\xF3";substr($x,0,1) =
"\x{FF}";print(Dump($x));'

What I have is:
 
SV = PV(0x14409d4) at 0x1470024
  REFCNT = 2
  FLAGS = (POK,pPOK,UTF8)
  PV = 0x147f6f8 "C\277\261C\262C\263"\0
  CUR = 7
  LEN = 8

The original string is UTF-8-ficated correcly, but only first byte of the
first UTF-8 caracter is replaced (the C\261 should be completelly replaced).


../perl -I../lib -MDevel::Peek -e '$x="\x{F1}\x{F2}\x{F3}";substr($x,0,1) =
"\xFF\xFF";print(Dump($x));'

What I have is:

SV = PV(0x14409d4) at 0x1470024
  REFCNT = 2
  FLAGS = (POK,pPOK,UTF8)
  PV = 0x14722d8 "~~C\262C\263"\0
  CUR = 6
  LEN = 7

Characters \xFF\xFF (~~) are included in the UTF-8 string without being
UTF-8-ficated

-- Ignasi Roca

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