Skip to content
pubscout

characters

1.4.1, released a year ago by dart.dev

Unicode and grapheme cluster aware string manipulation operations for Dart.

Flutter FavoriteWASM-readyRock solidQuiet but busy
$ flutter pub add characters
Source repository

What it does

Provides a Characters class and CharacterRange iterator to safely manipulate strings at the human-perceived character level. It avoids issues with splitting combined characters, surrogate pairs, or emojis that occur with standard code-unit based String operations.

AI-written summary of version 1.4.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to truncate or abbreviate text containing emojis or complex Unicode characters.
  • You are processing user-entered text where grapheme cluster boundaries matter.

Skip it when

  • You need to use regular expressions, as they are not grapheme cluster aware.
  • You require index-based string access, which is not supported due to variable grapheme cluster lengths.

Strengths

  • Safe handling of emojis and combined characters.
  • Bi-directional navigation and range manipulation via CharacterRange.
  • Zero dependencies.

Weaknesses

  • Operations cannot be index-based because grapheme clusters have varying lengths.
  • Regular expressions cannot be used safely directly on a sequence of characters.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
Characters? firstTagCharacters(Characters source) {
  var range = source.findFirst('<'.characters);
  if (range != null && range.moveUntil('>'.characters)) {
    return range.currentCharacters;
  }
  return null;
}

Alternatives

Packages that do the same job and could replace characters.

  • validators2

    String validation and sanitization for Dart.

  • bidi

    Converts logical RTL strings to their visual representation using the Unicode Bidirectional Algorithm.

  • emoji_extension

    Emojis for Flutter & Dart with Unicode 17.0 support and a powerful String extension

  • string_to_color

    Convert strings to colors, hex strings, or hex integers in Dart and Flutter.

Works with

Packages commonly used together with characters: ones it builds on, ones built on it, and its own family.