Letras Diferentes
Unicode research · Multilingual Text & Input Systems

Mixed-Script Text Processing: Script_Extensions, Segmentation and Identifier Policy

A guide to handling Latin, Cyrillic, Greek, Arabic and Common/Inherited Unicode characters in search, rendering and identifier security.

Technical referenceResearch and implementation notes

A single user-visible string can contain letters from several writing systems alongside digits, punctuation and combining marks. Mixed-script analysis cannot be reduced to rejecting every non-Latin character: legitimate quotations, code, research documents and multilingual names routinely cross script boundaries. Unicode's Script and Script_Extensions data support careful analysis, but application context determines the correct policy.

Script identifies a writing system, not a language

Unicode Script property values include Latin, Greek, Cyrillic, Arabic and many others. The property alone does not establish whether a string is English, Russian or Japanese. In multilingual contexts, a script can be shared by different languages and the same language can be written in multiple scripts.

Classifying mixed-script text as a rendering bug or an attack based only on two Script values produces false positives. Collect higher-level language and field-purpose information when available and distinguish natural-language prose from security-sensitive identifiers.

Common and Inherited require contextual handling

ASCII digits, many punctuation characters and separators have Script=Common. Combining marks may have Script=Inherited. Ignoring these distinctions can make a string look as though it switches scripts every time punctuation occurs.

Script_Extensions supplies a set of scripts relevant to certain characters, offering a more informative input for run segmentation and script-aware regex. Do not count each Common character as an independent foreign script; consider neighboring strong characters and the text-processing operation.

Font and shaping runs are not security identifiers

A text layout engine may split mixed Latin and Arabic text into runs with different direction, shaping and fallback fonts. The run boundaries may depend on script, font, bidi levels and language system selections.

A glyph run split is not a proof that the user is spoofing an identity. Equally, a suspicious identifier that happens to be shaped by one font remains suspicious if it contains visually confusable code points from multiple scripts.

Confusables can cross script boundaries

Latin a U+0061, Cyrillic а U+0430 and some other glyphs may be visually similar in particular fonts. A username that mixes Latin and Cyrillic letters can be a legitimate nickname or a deliberate lookalike. Rendering appearance alone cannot distinguish intent.

UTS #39 defines mechanisms such as confusable skeleton mappings and restriction levels for identifier analysis. Use a field-specific profile and versioned data; avoid presenting a skeleton as the authentic spelling or making a universal determination of user intent.

Script-aware regex needs property syntax and scope

Modern JavaScript regular expressions can use Unicode property escapes such as \p{Script=Greek} in Unicode-aware mode. Script_Extensions may be more appropriate for certain combining marks or shared-script symbols, but support and behavior must be tested in the target engine.

Unicode property matching operates on code points. It does not automatically segment grapheme clusters or understand whole-word language boundaries. For user-perceived character boundaries use UAX #29 segmentation or a suitable library, not a regex assumption that one scalar equals one visible letter.

Normalization does not erase script identity

NFC and NFD maintain canonical equivalence. NFKC may collapse some compatibility forms but it does not generally unify Greek and Latin lookalikes, nor does it guarantee immunity to spoofing. Even case folding can introduce multi-code-point results.

A robust pipeline keeps original text and separates normalization for equality, transliteration for search aliases, and confusable analysis for risk signals. Mixing these into one irreversible cleanup function makes debugging and auditing much harder.

Mixed direction adds an independent challenge

Arabic plus Latin and digits invokes the Unicode Bidirectional Algorithm. Resolved display order is separate from script identity. A visually reversed punctuation mark can result from bidi resolution even if all characters are valid and correctly encoded.

Use semantic direction controls or markup isolation for embedded identifiers where appropriate. Do not reverse code-unit order to compensate for a display issue; that changes data and may make a previously valid sequence unusable.

Identifier validation must be purpose-specific

Usernames, programming identifiers, domain labels and natural-language text have different acceptable character repertoires and threat models. UTS #39 provides principles for confusables and mixed-script detection, but products must choose their own supported profiles and exception handling.

A discussion forum should not apply the same strictness to an Arabic paragraph as to a login handle. For security decisions, show what scripts and characters triggered review, retain the actual scalar sequence and permit legitimate multilingual inputs through a documented process.

Create a reproducible review matrix

Collect examples using only Latin, Latin+Greek confusables, Latin+Cyrillic confusables, Arabic+Latin digits, Common punctuation and Inherited marks. Annotate each code point with Script and Script_Extensions where relevant.

Test display, search, regex classification, editing, confusable analysis and identifier policy as separate operations. Record Unicode version and toolchain because character property data can expand as new code points are assigned.

Reproducible specimen and observable boundaries

The following controlled example tests one narrowly defined distinction. It cannot alone establish correctness of a complete multilingual application. Preserve the original Unicode scalar values, identify any normalization or transliteration performed, and separately inspect font rendering, selection, data serialization and user-interface behavior.

const latinA = 'a', cyrillicA = '\u0430';
console.log(latinA === cyrillicA); // false; two distinct scalars
console.log(/\p{Script=Greek}/u.test('α')); // true
console.log(/\p{Script=Cyrillic}/u.test(cyrillicA)); // true
console.log(/\p{Script=Latin}/u.test(latinA)); // true
// Property matching does not perform UTS #39 confusable analysis.

For interop reports, record the input stream, chosen language or locale (if meaningful), browser or runtime version, relevant font files and output. When the outcome is only visually different, avoid changing source characters until the rendering or layout stage responsible for the mismatch has been isolated.

Technical comparison: data, algorithms and presentation

Component or caseConcrete inputCorrect interpretation
Latin small aU+0061Latin Script
Cyrillic small aU+0430Cyrillic, visually confusable with Latin in some fonts
Comma and digitsScript=Commonnot evidence of a foreign-language shift
Combining acuteU+0301often Script=Inherited; needs context
Arabic + Englishmixed bidi runslayout differs from text identity

Examples in this table represent distinct test contracts. Exact Unicode scalar equivalence is stronger than visual similarity, and an application may legitimately tailor text processing to language or product needs. Do not generalize one font's glyph appearance as a universal Unicode requirement.

Conformance and regression testing

  1. Latin small a. Preserve a fixture containing U+0061. Specify the Unicode version, application environment and expected observations. Verify that latin Script; compare the actual code-point stream separately from appearance.
  2. Cyrillic small a. Preserve a fixture containing U+0430. Specify the Unicode version, application environment and expected observations. Verify that cyrillic, visually confusable with Latin in some fonts; compare the actual code-point stream separately from appearance.
  3. Comma and digits. Preserve a fixture containing Script=Common. Specify the Unicode version, application environment and expected observations. Verify that not evidence of a foreign-language shift; compare the actual code-point stream separately from appearance.
  4. Combining acute. Preserve a fixture containing U+0301. Specify the Unicode version, application environment and expected observations. Verify that often Script=Inherited; needs context; compare the actual code-point stream separately from appearance.
  5. Arabic + English. Preserve a fixture containing mixed bidi runs. Specify the Unicode version, application environment and expected observations. Verify that layout differs from text identity; compare the actual code-point stream separately from appearance.

For broader coverage, exercise known difficult cases rather than only ASCII text: decomposed accents, supplementary characters, mixed direction, language-specific scripts and emoji sequences where relevant. Include expected negative results and document any product-specific tailoring. Keep fixtures stable and versioned so future Unicode or browser updates remain diagnosable.

Interpreting false positives

A difference is not automatically a failure. Some font and platform variation is permitted; conversely, two identical screenshots may hide distinct scalar streams. A reliable defect report cites the applicable rule, names the observed implementation layer, and demonstrates how its contract is violated without silently discarding the original text.

Primary standards and authoritative implementation documentation

These references define the relevant Unicode properties, web layout semantics or platform APIs. Unicode data files and browser conformance can evolve independently; record the tested version rather than presuming that every installed system has identical support.

  • Unicode Script Data UAX #44 — consult the primary specification or implementation reference for precise conformance wording, versions, property definitions and edge conditions.
  • Unicode Security UTS #39 — consult the primary specification or implementation reference for precise conformance wording, versions, property definitions and edge conditions.
  • Unicode Segmentation UAX #29 — consult the primary specification or implementation reference for precise conformance wording, versions, property definitions and edge conditions.
  • Unicode Bidirectional Algorithm UAX #9 — consult the primary specification or implementation reference for precise conformance wording, versions, property definitions and edge conditions.
  • MDN Unicode Property Escapes — consult the primary specification or implementation reference for precise conformance wording, versions, property definitions and edge conditions.

Within the Multilingual Text & Input Systems virtual silo, these already published studies provide additional context for source text, rendering, editing and interchange: