搜尋分類、套件與程式碼儲存庫

套件詳情v0.3.3

unorm_dart

Unicode 17.0 標準化 - NFC、NFD、NFKC、NFKD。這是 [walling/unorm](https://github.com/walling/unorm) 的 Dart 版本。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
47.6萬
喜歡數
31
Pub 分數
150

安裝套件

flutter pub add unorm_dart

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

unorm_dart 是 Unicode 17.0 標準化演算法的 Dart 實作,支援 NFC、NFD、NFKC 與 NFKD 格式。它能透過將 Unicode 字串標準化為標準表示,實現一致的文字處理,對於精確比對、搜尋與儲存至關重要。基於原始的 walling/unorm 庫,確保在 Android、iOS、Web、macOS、Windows 與 Linux 平台之間的跨平台相容性。適用於需要穩健處理帶變音符號、組合標記與特殊符號的國際化應用程式。

適用情境

  • 多語言應用程式中的文字比較
  • 搜尋和索引歸一化字串
  • 處理帶變音符號的使用者輸入
  • 跨區域的資料去重
  • 標準化API的Unicode輸入

主要特色

  • 支援所有四種Unicode標準化形式
  • 跨平台相容性
  • 輕巧且快速
  • 準確的 Unicode 17.0 相容性
  • 簡單、直覺的 API

適合對象

  • 國際化 Flutter 應用
  • 文字處理工具
  • 使用者驗證,不區分重音符號
  • 資料庫規範化工作流程
  • 地區化程式庫

使用建議

  • 可能會稍微增加封包大小
  • 需要仔細處理舊編碼中的邊緣情況
  • 不適用於非Unicode文字
  • 對非常大的文字批次的效能影響
  • 僅限歸一化——無其他Unicode操作

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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.

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單