in reply to Re^6: Seeking Perl docs about how UTF8 flag propagates
in thread Seeking Perl docs about how UTF8 flag propagates
Nitpicking (again): utf8::upgrade and utf8::downgrade do not return converted strings. They do the change inplace, and return a success indicator instead.
One solution is to take a copy (also note that for current Perls, use utf8 isn't needed):
sub verify_upgraded_length { my($s) = @_; my $u = $s; utf8::upgrade($u); return length($s) == length($u); } sub verify_downgraded_length { my($s) = @_; my $d = $s; utf8::downgrade($d); # dies if downgrade not possible return length($s) == length($d); }
|
|---|