liveBook · Manning

Combining character sequence

As explained in 100 Java Mistakes and How to Avoid Them

A combining character sequence is a base character together with one or more attached combining characters.

A combining character sequence joins a base character to one or more attached combining characters. Treating each char or code point as an independent user-visible character can split the sequence and detach its modifiers. section 6.1

Split text at character boundaries

Use BreakIterator.getCharacterInstance() for user-readable text: create the iterator, set the string, then advance by character boundaries rather than substring offsets. This recognizes surrogate pairs, combining sequences, and ligature clusters, keeping modifiers attached to their main symbols. section 6.1

Reduce boundary-related failures by following these rules:

  • Prefer special text APIs for user-readable text and isolate text-processing code. section 6.1
  • Use libraries such as ICU4J or dedicated utility methods instead of repeating fragile text logic. section 6.1
BreakIterator iterator = BreakIterator.getCharacterInstance();
iterator.setText(string);
iterator.first();
int from = iterator.next(rowLength * rowNumber);
int to = iterator.next(rowLength - 1);

A focused BreakIterator listing shows how to locate user-visible character boundaries before extracting a text segment. section 6.1

How 100 Java Mistakes and How to Avoid Them covers it

How deep it goes
Explains boundary-aware iteration and defers broader text-processing complexity to specialized APIs or libraries.
Examples
Uses emoji modifiers and BreakIterator character-boundary extraction as concrete examples.
What you can do after
Apply it via BreakIterator or ICU4J to process user-readable text without breaking attached characters.
How it connects
Connects combining character sequences with surrogate pairs, ligature clusters, Unicode code points, and BreakIterator.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 Java Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.