Skip to content

Instantly share code, notes, and snippets.

@dmaestro
Created March 19, 2019 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmaestro/041b7f23835e403f3044666535c52c36 to your computer and use it in GitHub Desktop.
Save dmaestro/041b7f23835e403f3044666535c52c36 to your computer and use it in GitHub Desktop.
Example of processing codepoint sequences in Perl 6
doug$ cat z2.pl6
use v6;
my $s = "Zoé";
.chr.print for |$s.NFC, 10;
.chr.print for |$s.NFD, 10;
doug$ perl6 z2.pl6
Zoé
Zoé
perl6 z2.pl6 | perl6 -e '$*IN.encoding(<utf8>); my $z1 = $*IN.get; my $z2 = $*IN.get; say $z1 eq $z2'
True
perl6 z2.pl6 | perl6 -e '$*IN.encoding(<utf8-c8>); my $z1 = $*IN.get; my $z2 = $*IN.get; say $z1 eq $z2'
False
@dmaestro
Copy link
Author

Paul Bennett on Facebook was asking about comparing two differently encoded Unicode strings in Perl 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment