Do you know where your variables are? | |
PerlMonks |
Re: pack on unpack with same templateby kcott (Archbishop) |
on Jul 28, 2021 at 01:30 UTC ( [id://11135414]=note: print w/replies, xml ) | Need Help?? |
G'day jjmoka, Your assumption seems reasonable. Here's a test script: #!/usr/bin/env perl use strict; use warnings; use utf8; use Test::More; my @test_strings = qw{ abc абв αβγ 🌌🪐🚀 🏻🏼🏽 𓀀𓀁𓀂 ◌◌◌̂ }; plan tests => 0+@test_strings; ok $_ eq pack('U0C*', unpack('U0C*', $_)) for @test_strings; Output:
As you suggest, there may be special cases. I couldn't think of any off the top of my head; other monks may know of some. You can just add more strings to @test_strings to test them (without needing to change anything else in the test script). You just said "I've found this code". Knowing something about the source and context of that code may provide scope for better answers. — Ken
In Section
Seekers of Perl Wisdom
|
|