Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A difference between Unicode and ASCII operators

I found out that Unicode and ASCII operators sometimes work differently when quote-interpolated.

Consider this:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => $a<<$k>>" }'

d => 1
b => 3
c => 5
a => 4

and this:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => $a«$k»" }'

c => c(5) a(4) b(3) d«c»
a => c(5) a(4) b(3) d«a»
b => c(5) a(4) b(3) d«b»
d => c(5) a(4) b(3) d«d»

But this works even when using an Unicode operator:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => {$a«$k»}" }'
d => 1
b => 3
a => 4
c => 5

Is this a bug, or there's an explanation I can't see?

like image 672
Fernando Santagata Avatar asked Apr 08 '19 09:04

Fernando Santagata


People also ask

What is the difference between Unicode and ASCII?

Unicode is the universal character encoding used to process, store and facilitate the interchange of text data in any language while ASCII is used for the representation of text such as symbols, letters, digits, etc. in computers.

What are the differences between ASCII and Unicode quizlet?

What is the difference between ASCII and Unicode? Unicode is a 16-bit character set which describes all of the keyboard characters. Why do we need to use Unicode for modern computers? Because you need all of the characters plus foreign ones too which is quite a lot of characters.

Why do we use Unicode instead of ASCII?

Unicode uses between 8 and 32 bits per character, so it can represent characters from languages from all around the world. It is commonly used across the internet. As it is larger than ASCII, it might take up more storage space when saving documents.

What is the difference between Unicode and binary?

They are one and the same - you can drop the u up front. Just write strings. So instantly you should see that the literal u'4f60' is just like writing actual '4f60' . A bytes literal - aka b'some literal' - is a series of bytes.


Video Answer


1 Answers

Seems to be fixed with commit 2835 from MasterDuke17:

  sub bracket_ending($matches) {
      my $check     := $matches[+$matches - 1];
      my str $str   := $check.Str;
      my $last  := nqp::substr($str, nqp::chars($check) - 1, 1);
-     $last eq ')' || $last eq '}' || $last eq ']' || $last eq '>'
+     $last eq ')' || $last eq '}' || $last eq ']' || $last eq '>' || $last eq '»'
  }
like image 165
LuVa Avatar answered Oct 27 '22 03:10

LuVa