removeDiacritics method
Removes diacritical marks from the string, replacing them with their base ASCII equivalents (e.g., 'é' becomes 'e').
This method is optimized to perform well by using a pre-computed map.
Implementation
String removeDiacritics() {
// If the string is empty, return an empty string immediately.
if (isEmpty) {
return '';
}
// Use the pre-computed reversed map for an efficient lookup.
// We map each character: if it's in our map, we replace it; otherwise,
// we keep the original. Then we join the characters back into a string.
return split('').map((String char) => _reverseAccentsMap[char] ?? char).join('');
}