yshrsmz / unorm-dart

Home Page:https://pub.dev/packages/unorm_dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to remove diacritics

Khader-1 opened this issue · comments

Isn't replacing all supposed to replace Å with A in this 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]/g");

  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.");
}

When trying it I didn't get that in fact the text appears to be the same before and after replacement.