Code points: what does length count?

Concepts explained

A code point is a numbered position in the Unicode catalogue. For example, A has the label U+0041. The U+ notation writes a Unicode number using hexadecimal, a number system with sixteen digits. You do not need to calculate these labels to use text in Pliro.

One shape can have several parts

Some visible characters combine several code points. An accented letter can be a ready-made letter, or a plain letter followed by a combining accent. A grapheme cluster is a group that behaves like one visible character. Emoji can form such groups too. See the Unicode explanation of combining characters.

Pliro’s length, text indexing, and text loops work with code points, not grapheme clusters or UTF-8 bytes.

# language: en
say length("🐢")
say length("👍🏽")

The answers are 1 and 2. The second example contains a thumbs-up code point and a skin-tone modifier. It may appear as one picture on your screen.

Why this matters

If you limit a player name to ten code points, that is not always ten visible letters. Cutting text at an arbitrary code-point position can separate an accent or an emoji component. Pliro does not currently provide a built-in grapheme-cluster counter.

Keep beginner examples simple, but do not assume that everybody’s name has one code point per visible letter. For a challenge, compare length("A") with length("AA"), then explain why byte size answers a different question.

UTF-8 · Indexing