This tool diagnoses and fixes Unicode encoding problems in Vietnamese text. Vietnamese diacritics can be stored two ways — precomposed (NFC) or decomposed (NFD) — and a mismatch causes accents to float over letters, search to miss results, and strings that look identical to compare as unequal.
How it works
The tool normalizes your input both ways using your browser’s built-in
String.prototype.normalize() function and compares each result against the
original:
- NFC (precomposed): each accented letter is a single code point. For example,
ếis stored as one code point (U+1EBF). - NFD (decomposed): the base letter plus separate combining marks.
ếbecomes three code points:e(U+0065) + combining circumflex accent (U+0302) + combining acute accent (U+0301).
By comparing code-point counts and the presence of combining marks, the tool identifies whether your text is NFC, NFD, mixed (some characters in each form), or plain ASCII with no diacritics.
Why this matters for Vietnamese specifically
Vietnamese has more distinct diacritical combinations than almost any other Latin-
script language. Each vowel can carry a tone mark (level, falling, rising, broken,
heavy) and a vowel modifier (circumflex, breve, horn) simultaneously — giving
characters like ộ, ướ, and ặ that each decompose into multiple combining
marks in NFD. A single paragraph of Vietnamese text may contain dozens of these
multi-mark characters, making encoding mismatches highly likely when text moves
between systems.
Example
The string Tiếng Việt looks identical in both forms on screen but encodes
differently:
- NFC: 10 visible characters → 10 code points
- NFD: 10 visible characters → more code points (each accented vowel expands)
A database WHERE name = 'Tiếng Việt' can return zero results when the stored
string is NFC but the query parameter is NFD, even though both display the same.
Normalize to NFC before storing and searching to prevent this class of bug.
When you see floating accents
Floating accents — tone marks that appear disconnected from their vowels — are the most visible symptom of NFD text in a font or renderer that does not correctly stack combining marks. The fix is almost always: convert to NFC. Copy the output NFC string into your document or database and the accents will seat correctly.
Which form to use
| Use case | Recommended form |
|---|---|
| Database storage | NFC |
| Web page text | NFC |
| Filenames (most systems) | NFC |
| macOS HFS+ filenames | NFD (macOS normalises to NFD) |
| String comparison / search | NFC (normalise both sides) |
| System that explicitly requires decomposed input | NFD |
NFC is the safe default for the vast majority of uses. Nothing is sent to a server; detection and conversion run entirely in your browser.