Sinhalata · sinhalata.com

One Word, Two Strings: ZWJ, Conjuncts, and Why Sinhala Text Breaks When You Copy It

Published October 2026 · Reviewed 9 November 2026 · Estwoco Team

Here is a bug report we have effectively received more than once, in different words: "I searched my document for this word and it says there are no matches, but I can see the word right there on the page." The text is Sinhala. It looks correct. It is not the same string.

This is not a Sinhala-specific mystery, but Sinhala is a particularly good place to see it, because a single visual syllable in Sinhala can be built from several Unicode code points, and some of those code points are invisible. When an invisible character is in the wrong place, nothing looks broken and everything stops matching. This article walks through what is actually in the string, where the zero-width joiner goes, and why the usual fix for text mismatches — normalisation — does nothing here.

How Sinhala is encoded, briefly

Sinhala occupies its own contiguous block in Unicode, from U+0D80 to U+0DFF, added in Unicode 3.0. Inside that block are three kinds of characters you need to keep apart:

The important consequence is that a Sinhala syllable which looks like one unit on screen is, at the data level, a short sequence. The renderer draws the sequence as a single visual cluster; the string stores the pieces separately. Everything that compares strings — search, sort, deduplication, form validation, word counting — sees the pieces, not the picture.

The sequences, spelled out

Take the consonant ක and build on it:

What you seeCode pointsWhat each part does
ක U+0D9A The consonant alone. It carries an inherent vowel sound.
කා U+0D9A U+0DCF Consonant plus the vowel sign that lengthens the vowel.
ක් U+0D9A U+0DCA Consonant plus al-lakuna: the vowel is cancelled, leaving a bare consonant.
ක්‍ර U+0D9A U+0DCA U+200D U+0DBB Consonant, al-lakuna, zero-width joiner, then ර. The ZWJ requests the joined form rather than a full separate consonant.
ක්‍ය U+0D9A U+0DCA U+200D U+0DBA Same pattern with ය, again producing the joined form.

The last two rows are where trouble starts. U+200D is the zero-width joiner, usually written ZWJ. It has no visible shape of its own. It tells the text renderer: treat the characters on either side as a single joined unit. In Sinhala that is how the yansaya and rakaransaya forms are requested, and how certain conjuncts are built.

Remove the ZWJ and you get a different string — consonant, al-lakuna, consonant — which many fonts will render differently, with the second consonant shown in full rather than joined. But in some fonts, at small sizes, and especially on low-resolution screens, the two renderings are close enough that a reader cannot tell which one they are looking at. That is the trap: the text is visually ambiguous and semantically unambiguous. The computer is right; your eyes are being reasonable but not precise.

Why this breaks things you would not expect

Because the mismatch is invisible, it surfaces as a series of unrelated-looking problems:

Why normalisation does not save you

The standard answer to "two strings that should be equal are not equal" is Unicode normalisation. Latin text has both composed and decomposed forms, so applying NFC collapses them into one representation and comparison works. It is a reasonable instinct, and for Sinhala it does not help.

Sinhala's letters and vowel signs do not have canonical decomposition mappings. There is no equivalent of "e with an accent" that splits into "e" plus a combining accent. The characters are already atomic. That means NFC and NFD leave a Sinhala string essentially as they found it: if the ZWJ is missing, normalisation will not add it, and if it is present, normalisation will not remove it.

So the mismatch is not a normalisation problem, it is an authoring problem. The two strings are genuinely different, both are valid Unicode, and no general-purpose cleanup step can decide which one the author meant. The fix has to happen when the text is produced.

What a converter has to guarantee

This is the constraint that shaped Sinhalata. If you are converting phonetic typing into Sinhala, you are not just choosing letters — you are choosing one sequence among several that may look the same. The converter therefore has to make the same choice every time, for the same input.

Three rules do most of the work:

The alternative — emitting whatever the font happens to accept — produces documents that look right on the machine that typed them and fail quietly everywhere else. That is the same failure mode as the legacy font era, just one layer deeper: the text is real Unicode, but it is inconsistently encoded Unicode.

How to check your own Sinhala text

If you suspect you are dealing with this, a few practical checks:

If you are building software that accepts Sinhala input, the same logic applies in reverse: define the canonical sequence you store, reject or rewrite the alternatives on input, and do your comparisons on that canonical form rather than on what a font renders.

The wider point

Unicode support is not a binary property that a language either has or lacks. It is a set of decisions about how sequences get produced and maintained. Sinhala has had a proper place in Unicode for a long time, and text that is technically valid Unicode can still be unusable for search and matching if it was authored inconsistently. The interesting work in Sinhala computing has moved on from "can we represent this at all" to "can we agree on exactly one representation — and produce it every time".

Sinhalata emits a single, consistent Unicode sequence for each syllable, so the text you produce matches the text you search for later.

Type consistent Unicode Sinhala at sinhalata.com →

Written and reviewed in-house

This article was written by the Estwoco team — the same people who design, build, and maintain the apps described here. We revise published pages when the software changes or when we find something we got wrong, and every revision is dated on the page.

Read how we research, review, and correct what we publish in our editorial policy.

Corrections and questions: contact@estwoco.com · All articles