Search packages, repositories and app categories

Package detailsv0.3.3

unorm_dart

Unicode 17.0 Normalization - NFC, NFD, NFKC, NFKD. This is a Dart port of [walling/unorm](https://github.com/walling/unorm).

AndroidiOSWebmacOSWindowsLinux
30-day downloads
536K
Likes
31
Pub points
150

Install package

flutter pub add unorm_dart

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

unorm_dart is a Dart implementation of Unicode 17.0 normalization algorithms, supporting NFC, NFD, NFKC, and NFKD forms. It enables consistent text processing by normalizing Unicode strings to standard representations, crucial for accurate comparison, searching, and storage. Based on the original walling/unorm library, it ensures cross-platform compatibility across Android, iOS, Web, macOS, Windows, and Linux. Ideal for internationalized applications requiring robust handling of accented characters, combining marks, and special symbols.

Use cases

  • Text comparison in multilingual apps
  • Searching and indexing normalized strings
  • Handling user input with diacritics
  • Data deduplication across locales
  • Standardizing Unicode input for APIs

Key features

  • Supports all four Unicode normalization forms
  • Cross-platform compatibility
  • Lightweight and fast
  • Accurate Unicode 17.0 compliance
  • Simple, intuitive API

Suitable for

  • Internationalized Flutter apps
  • Text processing tools
  • User authentication with accent-insensitive matching
  • Database normalization workflows
  • Localization libraries

Considerations

  • May increase bundle size slightly
  • Requires careful handling of edge cases in legacy encodings
  • Not suitable for non-Unicode text
  • Performance impact on very large text batches
  • Limited to normalization—no other Unicode operations

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

unorm_dart

Unit Test

Unicode 17.0 Normalization - NFC, NFD, NFKC, NFKD

Dart2 port of unorm

Functions

This module exports four functions: nfc, nfd, nfkc, and nfkd; one for each Unicode normalization. In the browser the functions are exported in the unorm global. In CommonJS environments you just require the module. Functions:

  • unorm.nfd(str) – Canonical Decomposition
  • unorm.nfc(str) – Canonical Decomposition, followed by Canonical Composition
  • unorm.nfkd(str) – Compatibility Decomposition
  • unorm.nfkc(str) – Compatibility Decomposition, followed by Canonical Composition

Usage

A simple usage example:

import "package:unorm_dart/unorm_dart.dart" as unorm;

void main() {
  var text = "The \u212B symbol invented by A. J. \u00C5ngstr\u00F6m " +
      "(1814, L\u00F6gd\u00F6, \u2013 1874) denotes the length " +
      "10\u207B\u00B9\u2070 m.";

  var combining = RegExp(r"[\u0300-\u036F]");

  print("Regular:  ${text}");
  print("NFC:      ${unorm.nfc(text)}");
  print("NFKC:     ${unorm.nfkc(text)}");
  print("NFKD: *   ${unorm.nfkd(text).replaceAll(combining, "")}");
  print(" * = Combining characters removed from decomposed form.");
}

Generating Unicode data

Manual Generation

To manually update the Unicode data and generate normalization files:

# Download latest Unicode data files
dart run tools/unicode_data_updater.dart

# Update lib/src/unormdata.dart
dart run tools/normalizer_gen.dart

Features and bugs

Please file feature requests and bugs at the issue tracker.

Categories

Source repository

Projects using this package

Rankings