utf-8 - Unicode 和 ASCII 运算符之间的区别

标签 utf-8 operators ascii raku

我发现 Unicode 和 ASCII 运算符在引号内插时有时会以不同的方式工作。

考虑一下:

$ 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

和这个:
$ 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»

但这即使在使用 Unicode 运算符时也有效:
$ 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

这是一个错误,还是有我看不到的解释?

最佳答案

似乎是用 commit 2835 修复的来自 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 '»'
  }

关于utf-8 - Unicode 和 ASCII 运算符之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55569744/

相关文章:

php - 比较 UTF-8 字符串

flutter - 运算符 '[]' 没有为类型 'Iterable<Meal>' 定义。尝试定义运算符 '[]' .dartundefined_operator

c - 多字节字符表示 ASCII&Hex

c - 函数名称前的星号是什么意思?

php - 如何使用运算符作为变量

ascii - ASCII 中的双引号

grep - 如何grep ASCII控制字符

ajax - 通过 AJAX 发布时字符编码错误

python - 运行源代码中包含 Unicode 字符的 Python 2.7 代码

c++ - Web 服务器中 utf-8 和 unicode 之间的转换