Unicode vs. ASCII 符号
可以在 Raku 中使用以下 Unicode 符号,而无需加载任何其他模块。其中一些具有可以使用 ASCII 独有字符键入的等效物。这些变体通常由比 Unicode 版本更多的字符组成,因此它们看起来更大。
下面参考 unicode 码点的各种属性。最终列表可以在这里找到:https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt.
字母字符
任何具有 Ll
(字母,小写),Lu
(字母,大写),Lt
(字母,标题),Lm
(字母,修饰符)或 Lo
(字母,其他)属性的代码点都可以像任何其他字母一样使用 ASCII 范围内的字符。
数字字符
任何具有 Nd
(数字,十进制数字)属性的代码点都可以用作任何数字的数字。例如:
my $var = 19; # U+FF11 U+FF19
say $var + 2; # OUTPUT: «21»
数字值
任何具有 No
(Number,other)或 Nl
(Number,letter)属性的代码点都可以单独用作数值,例如 ½ 和 ⅓。 (这些不是十进制数字,因此不能组合。)例如:
my $var = ⅒ + 2 + Ⅻ; # here ⅒ is No and Rat and Ⅻ is Nl and Int
say $var; # OUTPUT: «14.1»
空白字符
除了空格和制表符,您还可以使用具有 Zs
(分隔符,空格),Zl
(分隔符,行)或 Zp
(分隔符,段落)属性的任何其他 unicode 空白字符。
其它可接受的单代码点
此列表包含 Raku 中具有特殊含义的单个代码点及其 ASCII 等价物。
Symbol | Codepoint | ASCII | Remarks |
---|---|---|---|
« | U+00AB | « | as part of «» or .« or regex left word boundary |
¯ | U+00AF | - | (must use explicit number) as part of exponentiation (macron is an alternative way of writing a minus) |
² | U+00B2 | **2 | can be combined with ⁰..⁹ |
³ | U+00B3 | **3 | can be combined with ⁰..⁹ |
¹ | U+00B9 | **1 | can be combined with ⁰..⁹ |
» | U+00BB | » | as part of «» or .» or regex right word boundary |
× | U+00D7 | * | |
÷ | U+00F7 | / | |
π | U+03C0 | pi | 3.14159_26535_89793_238e0 |
τ | U+03C4 | tau | 6.28318_53071_79586_476e0 |
‘ | U+2018 | ' | as part of ‘’ or ’‘ |
’ | U+2019 | ' | as part of ‘’ or ‚’ or ’‘ |
‚ | U+201A | ' | as part of ‚‘ or ‚’ |
“ | U+201C | " | as part of “” or ”“ |
” | U+201D | " | as part of “” or ”“ or ”” |
„ | U+201E | " | as part of „“ or „” |
… | U+2026 | … | |
⁰ | U+2070 | **0 | can be combined with ⁰..⁹ |
⁴ | U+2074 | **4 | can be combined with ⁰..⁹ |
⁵ | U+2075 | **5 | can be combined with ⁰..⁹ |
⁶ | U+2076 | **6 | can be combined with ⁰..⁹ |
⁷ | U+2077 | **7 | can be combined with ⁰..⁹ |
⁸ | U+2078 | **8 | can be combined with ⁰..⁹ |
⁹ | U+2079 | **9 | can be combined with ⁰..⁹ |
⁺ | U+207A | | | (must use explicit number) as part of exponentiation |
⁻ | U+207B | - | (must use explicit number) as part of exponentiation |
∅ | U+2205 | set() | (empty set) |
∈ | U+2208 | (elem) | |
∉ | U+2209 | !(elem) | |
∋ | U+220B | (cont) | |
∌ | U+220C | !(cont) | |
− | U+2212 | - | |
∖ | U+2216 | (-) | |
∘ | U+2218 | o | |
∞ | U+221E | Inf | |
∩ | U+2229 | (&) | |
∪ | U+222A | (|) | |
≅ | U+2245 | =~= | |
≠ | U+2260 | != | |
≤ | U+2264 | <= | |
≥ | U+2265 | >= | |
⊂ | U+2282 | (<) | |
⊃ | U+2283 | (>) | |
⊄ | U+2284 | !(<) | |
⊅ | U+2285 | !(>) | |
⊆ | U+2286 | (<=) | |
⊇ | U+2287 | (>=) | |
⊈ | U+2288 | !(<=) | |
⊉ | U+2289 | !(>=) | |
⊍ | U+228D | (.) | |
⊎ | U+228E | (+) | |
⊖ | U+2296 | (^) | |
𝑒 | U+1D452 | e | 2.71828_18284_59045_235e0 |
「 | U+FF62 | Q// | as part of 「」 (Note: Q// variant cannot be used bare in regexes) |
」 | U+FF63 | Q// | as part of 「」 (Note: Q// variant cannot be used bare in regexes) |
原子运算符
原子运算符将 U+269B
⚛ ATOM SYMBOL 合并到其中。它们的 ASCII 等价物是普通的子程序,而不是运算符:
my atomicint $x = 42;
$x⚛++; # Unicode version
atomic-fetch-inc($x); # ASCII version
ASCII 替代方案如下:
Symbol | ASCII | Remarks |
---|---|---|
⚛= | atomic-assign | |
⚛ | atomic-fetch | this is the prefix:<⚛> operator |
⚛+= | atomic-add-fetch | |
⚛-= | atomic-sub-fetch | |
⚛−= | atomic-sub-fetch | this operator uses U+2212 minus sign |
++⚛ | atomic-inc-fetch | |
⚛++ | atomic-fetch-inc | |
–⚛ | atomic-dec-fetch | |
⚛– | atomic-fetch-dec |
多代码点
此列表包含多个代码点运算符,这些运算符需要对其 ASCII 等价物项进行特殊组合。请注意,代码点以空格分隔显示,但在使用时应作为相邻代码点输入。
Symbol | Codepoints | ASCII | Since | Remarks |
---|---|---|---|---|
»=» | U+00BB = U+00BB | »[=]» | v6.c | uses ASCII ‘=’ |
«=« | U+00AB = U+00AB | «[=]« | v6.c | uses ASCII ‘=’ |
«=» | U+00AB = U+00BB | «[=]» | v6.c | uses ASCII ‘=’ |
»=« | U+00BB = U+00AB | »[=]« | v6.c | uses ASCII ‘=’ |