String well-formedness and Unicode normalization answer different questions. isWellFormed asks whether every UTF-16 surrogate is paired correctly. toWellFormed replaces each unpaired surrogate with U+FFFD. normalize instead transforms canonically or compatibly equivalent character sequences into a selected normalization form. A string can be well-formed and still not be normalized, or normalized-looking and still contain an unpaired surrogate that requires separate handling.
This specialist guide belongs to the Websites root. It also connects to The Gold Standard of Education | Learning That Transfers into Life and the How X Works hub. The worked cases are original teaching examples; their values and event logs are stated so each conclusion can be checked.
eduKateSG · Websites
Find your next learning step
Use the routes to inspect UTF-16 code units, identify surrogate pairs and isolated surrogates, compare repair with normalization, test composed and decomposed accents, preserve semantic limits, and design checks that name which property was actually verified.
ROUTE 1 · CHAPTERS 1–3
Build the first model
Name the input, state, conversion or predicate before following user-visible results.
ROUTE 2 · CHAPTERS 4–5
Trace the decisive branch
Work the accepted path and the nearest boundary case with original examples.
ROUTE 3 · CHAPTERS 6–8
Change one premise
Rebuild the mechanism when state, value, realm, timing or object kind changes.
ROUTE 4 · CHAPTERS 9–10
Handle limits and failures
Keep abrupt completion, availability and application limits visible.
ROUTE 5 · CHAPTERS 11–12
Verify and explain
Use a decisive fixture, changed-context check and concise final account.
Chapter contents
Build the first model · Chapters 1–3
1. Inspect UTF-16 code units before naming characters
Trace the decisive branch · Chapters 4–5
Change one premise · Chapters 6–8
6. Show a well-formed string that is not NFC
Handle limits and failures · Chapters 9–10
Verify and explain · Chapters 11–12
CHAPTER 1 OF 12 · Build the first model
1. Inspect UTF-16 code units before naming characters
The short answer is that ECMAScript strings are sequences of 16-bit code units and can contain isolated surrogate values. Chapter 1 focuses on inspect utf-16 code units before naming characters. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Build a string from code units 0x0041, 0xD83D, 0xDE00 and 0x0042 and identify the valid pair. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for inspect utf-16 code units before naming characters is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Remove the trailing surrogate and mark the leading surrogate as unpaired. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: A code-unit count is not automatically a code-point or grapheme count. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Log code units in hexadecimal and iterate code points separately. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of inspect utf-16 code units before naming characters should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 2 OF 12 · Build the first model
2. Use isWellFormed as a structural predicate
The short answer is that isWellFormed returns false when any leading or trailing surrogate is not part of a valid pair. Chapter 2 focuses on use iswellformed as a structural predicate. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Test A plus one valid emoji surrogate pair and obtain true. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for use iswellformed as a structural predicate is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Append an isolated low surrogate and obtain false. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: The predicate says nothing about normalization, spelling, display or permitted characters. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Assert the result alongside the exact offending code-unit index. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of use iswellformed as a structural predicate should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 3 OF 12 · Build the first model
3. Repair unpaired surrogates with toWellFormed
The short answer is that toWellFormed replaces each unpaired surrogate with U+FFFD while preserving valid pairs and other code units. Chapter 3 focuses on repair unpaired surrogates with towellformed. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Repair a string containing A, an isolated high surrogate and B. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for repair unpaired surrogates with towellformed is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Replace the isolated surrogate with a valid pair and show that no replacement is inserted. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Replacement is lossy and cannot recover the intended missing code unit. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Compare code units before and after and count replacement positions. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of repair unpaired surrogates with towellformed should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
The short answer is that a leading surrogate immediately followed by a trailing surrogate represents one supplementary code point and survives toWellFormed. Chapter 4 focuses on keep valid surrogate pairs intact. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Use the pair D83D DE00 for U+1F600 and verify unchanged output. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for keep valid surrogate pairs intact is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Swap their order and observe two unpaired surrogates repaired separately. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Pair validity concerns adjacency and order, not visual expectations. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Inspect codePointAt and code-unit indices around the pair. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of keep valid surrogate pairs intact should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 5 OF 12 · Trace the decisive branch
5. Define normalization as an equivalence transformation
The short answer is that normalize applies NFC, NFD, NFKC or NFKD to well-defined character sequences rather than checking surrogate pairing. Chapter 5 focuses on define normalization as an equivalence transformation. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Compare precomposed é with e plus combining acute and normalize both to NFC. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for define normalization as an equivalence transformation is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Normalize both to NFD and inspect the decomposed sequence. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Canonical equivalence does not make the original code-unit sequences identical. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Record chosen form, input code points and output code points. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of define normalization as an equivalence transformation should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
The short answer is that well-formed UTF-16 can contain a decomposed sequence that NFC would compose. Chapter 6 focuses on show a well-formed string that is not nfc. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Use e followed by U+0301, obtain true from isWellFormed, then obtain é under NFC. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for show a well-formed string that is not nfc is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Start with precomposed é and confirm the well-formed result stays true. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Well-formedness cannot substitute for a normalization check. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Compare s.isWellFormed() with s === s.normalize(‘NFC’). Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of show a well-formed string that is not nfc should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
The short answer is that toWellFormed changes isolated surrogates but does not select NFC, NFD, NFKC or NFKD. Chapter 7 focuses on show repair without normalization. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Repair an isolated surrogate beside a decomposed accent sequence. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for show repair without normalization is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. After repair, call normalize(‘NFC’) as a separate second operation. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: The order and policy should be explicit because both operations can change code units for different reasons. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Log the result after each named stage rather than only the final string. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of show repair without normalization should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 8 OF 12 · Change one premise
8. Separate canonical from compatibility forms
The short answer is that NFKC and NFKD can erase compatibility distinctions that NFC and NFD preserve. Chapter 8 focuses on separate canonical from compatibility forms. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Normalize a fullwidth Latin letter with NFC and NFKC and compare outputs. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for separate canonical from compatibility forms is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Use a plain ASCII letter and show no change under either form. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Compatibility normalization can remove distinctions an application intends to retain. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Choose a form from an application requirement, not from a generic cleanliness rule. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of separate canonical from compatibility forms should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 9 OF 12 · Handle limits and failures
9. Treat U+FFFD as evidence of repair, not proof of origin
The short answer is that toWellFormed inserts U+FFFD for unpaired surrogates, but an input can also contain a literal U+FFFD. Chapter 9 focuses on treat u+fffd as evidence of repair, not proof of origin. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Compare a literal replacement character with one produced by repair. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for treat u+fffd as evidence of repair, not proof of origin is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Retain an out-of-band repair count to distinguish the controlled fixture. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: The final string alone may not reveal whether replacement occurred earlier. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Record provenance or validation results before discarding the original input. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of treat u+fffd as evidence of repair, not proof of origin should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
CHAPTER 10 OF 12 · Handle limits and failures
10. Handle unsupported normalization names
The short answer is that String.prototype.normalize accepts the defined form names and rejects other names. Chapter 10 focuses on handle unsupported normalization names. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Call normalize(‘NFC’) successfully and normalize(‘NFX’) to record RangeError. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for handle unsupported normalization names is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Omit the argument and observe the default NFC form. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: A valid form name still does not make normalization appropriate for every identifier or display string. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. Assert error class and selected form without depending on engine message text. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of handle unsupported normalization names should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
The short answer is that a robust boundary can check structure, decide whether repair is allowed, then apply a chosen normalization policy if the domain requires it. Chapter 11 focuses on design an ordered text-ingress policy. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Validate a user label, reject unpaired surrogates and normalize accepted input to NFC. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for design an ordered text-ingress policy is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Change the domain to forensic logging and preserve original code units instead of repairing. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: There is no universal sequence that fits display text, identifiers, signatures and archival evidence. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. State whether the boundary rejects, repairs, normalizes or preserves. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of design an ordered text-ingress policy should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
The short answer is that a complete explanation states structural status, repair action, normalization form, changed code points and application limit. Chapter 12 focuses on report the two properties separately. Begin with the ECMAScript string’s UTF-16 code units, code-point boundaries, paired or unpaired surrogate status, isWellFormed result, toWellFormed replacement positions, selected normalization form, canonical or compatibility mapping, resulting code units and application policy. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.
Worked example. Document a well-formed decomposed label that becomes NFC without any surrogate repair. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.
A useful first-principles question for report the two properties separately is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.
Now change exactly one premise. Change the fixture to an isolated surrogate and rebuild the report. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.
The main limit is this: Do not say Unicode-valid when only one narrow property was checked. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.
Practical evidence check. End with code-unit evidence, named operation results and one policy decision. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.
A concise final explanation of report the two properties separately should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.
Contents · Previous chapter · Return to the Websites subject guide
Frequently asked questions
Is every well-formed string normalized?
No. A well-formed string can still use a decomposed sequence that changes under NFC.
Does normalize repair unpaired surrogates?
Do not treat it as the surrogate-repair API; use isWellFormed and toWellFormed for that explicit job.
What does toWellFormed replace?
Each unpaired leading or trailing surrogate is replaced with U+FFFD.
Does toWellFormed change valid emoji surrogate pairs?
No. A correctly ordered pair is preserved.
Are NFC and NFKC interchangeable?
No. NFKC applies compatibility mappings and can remove distinctions that NFC preserves.
Does well-formedness prove text is safe or meaningful?
No. It is one structural property; application validation and security policy remain separate.
Continue through the verified reading routes
Start with the wider system
The Gold Standard of Websites · The Gold Standard of Education | Learning That Transfers into Life · How X Works hub
Compare the closest mechanisms
Counting characters, bytes and grapheme clusters · String.raw literal segments and converted substitutions · TextEncoder encodeInto progress at surrogate boundaries · TextDecoder fatal and replacement decoding
Choose the next lesson by reader job
Use the subject root to move from this focused mechanism to the next verified question. Follow a specialist link when its preconditions match your code; return to the wider hub when the next task belongs to a different system.
Authoritative sources and evidence checks
ECMAScript 2027: String.prototype.isWellFormed · ECMAScript 2027: String.prototype.toWellFormed · ECMAScript 2027: String.prototype.normalize · Unicode Standard Annex #15: Normalization Forms
ECMAScript defines String well-formedness, replacement of unpaired surrogates and the normalize method. Unicode Standard Annex #15 defines NFC, NFD, NFKC and NFKD. These standards describe structure and normalization; they do not decide application identity, security or language policy.