Can Perl 5.12 start interpreting string literals with utf8 semantics without shattering backwards compatibility? I didn't think that was likely to happen. If it does it won't just be my examples here that break! :)
I tried to manufacture an example to demo your assertion that if the string were utf8-on prior to assignment the result would differ, but I haven't been able to come up with anything. Certainly concatenating onto the end of an existing string the results would differ, but wholesale assignment?? How would you change the following example to illustrate your point?
I also have to confess that I don't understand what you mean when you say that altering the PV is not the same as assigning to a string under utf8 semantics. Certainly you'd need to alter the PV (and other values, possibly flags too) following the rules of unicode handling -- for instance, checking for illegal sequences at splice points. Is that what you mean? I've spelunked a lot of the utf8 code in sv.c and I don't recall having seen any constructs I didn't recognize.#!/usr/bin/perl use strict; use warnings; use Encode qw( _utf8_on ); use Devel::Peek qw( Dump ); my $foo; $foo = 'foo'; Dump($foo); my $bar; _utf8_on($bar); $bar = 'bar'; Dump($bar); __END__ Outputs: SV = PV(0x1801660) at 0x180b59c REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x365f20 "foo"\0 CUR = 3 LEN = 4 SV = PV(0x1801678) at 0x180b56c REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x300bd0 "bar"\0 CUR = 3 LEN = 4
And thanks for the suggestion on pack. Maybe if I'd used that in the OP there'd be less blood on the floor! :)
In reply to Re^3: Never touch (or look at) the UTF8 flag!!
by creamygoodness
in thread Interventionist Unicode Behaviors
by creamygoodness
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |