class Uni

A string of Unicode codepoints

class Uni does Positional[uint32does Stringy { }

Unlike Str, which is made of Grapheme clusters, Uni is string strictly made of Unicode codepoints. That is, base characters and combining characters are separate elements of a Uni instance.

Uni presents itself with a list-like interface of integer Codepoints.

Typical usage of Uni is through one of its subclasses, NFC, NFD, NFKD and NFKC, which represent strings in one of the Unicode Normalization Forms of the same name.

Methods

method new

method new(*@codes --> Uni:D)

Creates a new Uni instance from the given codepoint numbers.

method NFC

method NFC(Uni:D: --> NFC:D)

Returns a NFC (Normal Form Composed)-converted version of the invocant.

method NFD

method NFD(Uni:D: --> NFD:D)

Returns a NFD (Normal Form Decomposed)-converted version of the invocant.

method NFKC

method NFKC(Uni:D: --> NFKC:D)

Returns a NFKC (Normal Form Compatibility Composed)-converted version of the invocant.

method NFKD

method NFKD(Uni:D: --> NFKD:D)

Returns a NFKD (Normal Form Compatibility Decomposed)-converted version of the invocant.

method codes

method codes(Uni:D: --> Int:D)

Returns the number of codepoints in the invocant.

method elems

method elems(Uni:D: --> Int:D)

Returns the number of codepoints in the invocant.

Type Graph

Type relations for Uni
perl6-type-graph Uni Uni Any Any Uni->Any Positional Positional Uni->Positional Stringy Stringy Uni->Stringy Mu Mu Any->Mu NFKD NFKD NFKD->Uni NFD NFD NFD->Uni NFC NFC NFC->Uni NFKC NFKC NFKC->Uni

Expand above chart

Routines supplied by role Positional

Uni does role Positional, which provides the following routines:

(Positional) method of

method of()

Returns the type constraint for elements of the positional container. Defaults to Mu.

(Positional) method elems

method elems()

Should return the number of available elements in the instantiated object.

(Positional) method AT-POS

method AT-POS(\position)

Should return the value / container at the given position.

(Positional) method EXISTS-POS

method EXISTS-POS(\position)

Should return a Bool indicating whether the given position actually has a value.

(Positional) method STORE

method STORE(\values:$initialize)

This method should only be supplied if you want to support the:

my @a is Foo = 1,2,3;

syntax for binding your implementation of the Positional role.

Should accept the values to (re-)initialize the object with. The optional named parameter will contain a True value when the method is called on the object for the first time. Should return the invocant.