How Chromium Uses ICU for Dates, Collation, and Segmentation

This article provides an overview of how the Chromium web browser leverages the International Components for Unicode (ICU) library to support global users. Specifically, it examines how Chromium integrates ICU into its core architecture, the Blink rendering engine, and the V8 JavaScript engine to handle localized date formatting, language-sensitive string collation, and complex text segmentation across hundreds of different locales.

Date Formatting

Chromium relies on ICU to display dates and times in a way that matches the cultural expectations of the user. Because date formats vary wildly—such as month-day-year in the United States versus day-month-year in Europe, or even entirely different calendar systems like the Japanese Imperial or Islamic calendars—hardcoding these rules is impossible.

Chromium uses ICU’s DateFormat and SimpleDateFormat classes, which are powered by the Unicode Common Locale Data Repository (CLDR). ICU handles date formatting in two primary areas within the browser:

  1. The Browser UI and Blink: When Chromium renders native browser elements—such as the download history page, certificate expiration dates, or HTML <input type="date"> fields—it passes a timestamp to ICU. ICU then formats the output string according to the browser's active locale, automatically applying the correct time zone names, day names, and punctuation.
  2. The V8 JavaScript Engine: Web developers use the Intl.DateTimeFormat API to format dates on websites. V8 delegates these JavaScript calls directly to the underlying ICU C++ library, ensuring that web applications have access to the exact same localization data as the browser itself.

Collation

Collation is the process of comparing and sorting strings of text according to the orthographic rules of a specific language. Simple binary comparison (comparing Unicode code points) fails for most human languages. For example, in Swedish, the letter "ö" is sorted after "z", whereas in German, it is sorted near "o".

Chromium utilizes ICU’s Collator class, which is a complete implementation of the Unicode Collation Algorithm (UCA). This integration is used for:

  • JavaScript Sorting: When a web application calls String.prototype.localeCompare() or uses the Intl.Collator object, V8 uses ICU to determine the correct sort order. ICU evaluates the strings based on the requested locale and sensitivity settings (such as ignoring case or accents).
  • Browser Internals: Chromium uses ICU collation to sort user-facing lists inside the browser, such as alphabetically organizing bookmark folders, autofill suggestions, and settings menus.
  • Find-in-Page: When a user presses Ctrl+F (or Cmd+F) to search for text on a webpage, Chromium uses ICU's string search capabilities (which are built on top of collation rules) to find matches. This allows the browser to match characters regardless of whether the user typed an accent mark, depending on the language's rules.

Text Segmentation

Text segmentation is the process of locating boundaries between graphemes (user-perceived characters), words, sentences, and lines of text. While English predominantly uses spaces and punctuation to separate words and sentences, languages like Chinese, Japanese, Thai, and Khmer do not use spaces between words.

To solve this, Chromium relies heavily on ICU’s BreakIterator class. ICU uses rule-based state machines and built-in language dictionaries to determine where text boundaries logically occur. Chromium applies this in several ways:

  • Line Breaking in Blink: When rendering a webpage, the Blink layout engine must know where it is legally allowed to wrap text to the next line. Blink feeds the text into ICU’s line-break iterator to ensure words are not broken in the middle, and that punctuation (like a closing parenthesis or a period) does not end up isolated at the beginning of a new line.
  • User Interaction: When a user double-clicks a word to highlight it, or uses Ctrl+Arrow keys to jump the cursor from word to word, Chromium uses ICU's word-break iterator to identify the start and end of the word. For languages like Thai, ICU uses dictionary-based lookups to guess the word boundaries accurately.
  • Character Deletion: Some characters, like complex emojis (e.g., a family emoji or a thumbs-up with a skin tone modifier), are actually made of multiple Unicode code points joined together. When a user presses the Backspace key, Chromium uses ICU's grapheme cluster break iterator to delete the entire perceived character at once, rather than deleting it piece by piece.
  • The Intl.Segmenter API: V8 exposes ICU’s segmentation capabilities directly to web developers through the Intl.Segmenter JavaScript API, allowing websites to perform locale-sensitive text breaking without needing to ship their own heavy language dictionaries.