Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show how to interpolate with unicode
  • Loading branch information
gfldex committed Jul 23, 2016
1 parent b1e3270 commit af84958
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions doc/Language/quoting.pod6
Expand Up @@ -75,9 +75,10 @@ L<say> B<">My favorite color is B<$color>!B<">
My favorite color is blue!
The C<qq> form -- usually written using double quotes -- allows for
interpolation of variables, i.e., variables can be written within the string
so that the content of the variable is inserted into the string. It is also
possible to escape variables within a C<qq>-quoted string:
interpolation of backslash sequences and variables, i.e., variables can be
written within the string so that the content of the variable is inserted into
the string. It is also possible to escape variables within a C<qq>-quoted
string:
=for code :allow<B>
say B<">The B<\>$color variable contains the value '$color'B<">;
Expand Down Expand Up @@ -126,8 +127,24 @@ X<|&>
Postcircumfix operators and therefore L<subscripts|/language/subscripts> are
interpolated as well.
my %h = :1st; say "abc%h<st>ghi";
OUTPUT«abc1ghi␤»
my %h = :1st; say "abc%h<st>ghi";
OUTPUT«abc1ghi␤»
To enter unicode sequences use C<\x> or C<\x[]> with the hex-code of the
character or a list of characters.
my $s = "I \x[2665] Perl 6!";
dd $s;
OUTPUT«Str $s = "I ♥ Perl 6!"␤»
my $s = "I really \x[2661,2665,2764,1f495] Perl 6!";
dd $s;
OUTPUT«Str $s = "I really ♡♥❤💕 Perl 6!"␤»
You can also use unicode names with C<\c[]>.
my $s = "Camelia \c[BROKEN HEART] my \c[HEAVY BLACK HEART]!";
dd $s;
OUTPUT«Str $s = "Str $s = "Camelia 💔 my ❤!"␤»
=head2 Word quoting: qw
X<|qw word quote>X«|< > word quote»
Expand Down

0 comments on commit af84958

Please sign in to comment.