On Friday, 28 October 2016 at 12:52:04 UTC, Marc Schütz wrote:
On Friday, 28 October 2016 at 11:24:28 UTC, Alfred Newman wrote:
[...]

import std.stdio;
import std.algorithm;
import std.uni;
import std.conv;

void main()
{
    auto str = "très élégant";
    immutable accents = unicode.Diacritic;
    auto removed = str
        .normalize!NFD
        .filter!(c => !accents[c])
        .to!string;
    writeln(removed);  // prints "tres elegant"
}

This first decomposes all characters into base and diacritic, and then removes the latter.

Cool. That looks pretty neat and it should cover all cases.

Reply via email to