in reply to pack on unpack with same template
AFAICT, the effect of pack('U0C*', unpack('U0C*', ...)) is the same as utf8::upgrade. See also What does utf8::upgrade actually do.
use warnings; use strict; use Devel::Peek; my @tests = ( "Hello", "Hell\xF6", "\N{U+20AC}", "\xE2\x82\xAC", ); for my $in (@tests) { my $out = pack('U0C*', unpack('U0C*', $in)); print STDERR "##### ##### ##### pack/unpack ##### ##### #####\n"; Dump($in); Dump($out); print STDERR "##### upgrade #####\n"; Dump($in); utf8::upgrade($in); Dump($in); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pack on unpack with same template
by ikegami (Patriarch) on Jul 28, 2021 at 09:31 UTC | |
by ikegami (Patriarch) on Jul 28, 2021 at 21:11 UTC |