characters
1.4.1, released a year ago by dart.dev
Unicode and grapheme cluster aware string manipulation operations for Dart.
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.
83Compare - bidi
Converts logical RTL strings to their visual representation using the Unicode Bidirectional Algorithm.
74Compare - emoji_extension
Emojis for Flutter & Dart with Unicode 17.0 support and a powerful String extension
54Compare - string_to_color
Convert strings to colors, hex strings, or hex integers in Dart and Flutter.
42Compare
Works with
Packages commonly used together with characters: ones it builds on, ones built on it, and its own family.
- dartxBuilt on charactersCollection of useful static extension methods for Dart core types.
- dart_consoleBuilt on charactersA helper library for command-line applications requiring advanced control over input/output.
- moreBuilt on charactersA collection of utility extensions and specialized data structures for Dart.
- cborBuilt on charactersA Dart library for RFC8949‑compliant CBOR encoding and decoding.
- configBuilt on charactersTyped CLI argument and config file parser with env support
- json_schema_builderBuilt on charactersBuild and validate JSON Schemas in Dart with a fluent, type‑safe API
- stringsBuilt on charactersLarge collection of String functions extending the String class and supporting nullable Strings safely.
- noctermBuilt on charactersFramework for building terminal user interfaces with Flutter‑like components and hot reload.