Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: pack on unpack with same template

by haukex (Archbishop)
on Jul 28, 2021 at 09:07 UTC ( [id://11135425]=note: print w/replies, xml ) Need Help??


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

    This is what I suspected it was doing when I saw the question. I did not have a chance to verify it.

    Seeking work! You can reach me at ikegami@adaelis.com

      Yup, confirmed that changing to the "upgraded" internal storage format is the only effect other than making a copy.

      Seeking work! You can reach me at ikegami@adaelis.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-19 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found