removeAccentsFromGreeklish function

String removeAccentsFromGreeklish(
  1. String greeklishTextWithAccents
)

Converts a given any-case text in Greeklish greeklishTextWithAccents, into the equivalent, simplified version where accents are removed.

For example, "Énas Kósmos" is converted to "Enas Kosmos".

This can be useful when you are searching in text.

Implementation

String removeAccentsFromGreeklish(final String greeklishTextWithAccents) {
  String greeklishTextWithoutAccents = '';
  for (final String c in greeklishTextWithAccents.split('')) {
    final String? cWithoutAccent = _accentsToPlainGreeklish[c];
    greeklishTextWithoutAccents += cWithoutAccent ?? c;
  }
  return greeklishTextWithoutAccents.toString();
}