📘 All Unicode digits in Perl 6

📘 All Unicode digits in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.

Print all Unicode digits.

Perl 6 has the best support of Unicode among the modern programming languages. When talking about digits, it is worth remembering that the Unicode standard marks as digits much more than the regular ten characters used in English, for example.

Let us iterate over the whole range of codepoints and select the digits using the <:digit> character class in the regex.

for 1 .. 0x10FFFD {
    my $char = $_.chr;
    print $char if $char ~~ /<:digit>/;

The program prints 580 characters. Let us list some of them:


If you want to know the name of the Unicode digit, call the uniname method on the character:

say $char ~ ' ' ~ $char.uniname if $char ~~ /<:digit>/;

For example, Arabic digits 0 to 9 have simple names such as DIGIT ZERO; another set of Arabic digits ٠,١, ٢, etc., up to ٩ has names such as ARABIC-INDIC DIGIT THREE.

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code