Re: Best approach to handle accented letters

2016-10-28 Thread Alfred Newman via Digitalmars-d-learn
On Friday, 28 October 2016 at 15:08:59 UTC, Chris wrote: On Friday, 28 October 2016 at 14:31:47 UTC, Chris wrote: [...] What you basically do is you pass the logic on to `map` and `map` applies it to each item in the range (cf. [1]): [...] The life is beautiful ! Thx.

Re: Best approach to handle accented letters

2016-10-28 Thread Chris via Digitalmars-d-learn
On Friday, 28 October 2016 at 14:31:47 UTC, Chris wrote: On Friday, 28 October 2016 at 13:50:24 UTC, Alfred Newman wrote: It boils down to something like: if (c in _accent) return _accent[c]; else return c; Just a normal lambda (condition true) ? yes : no; I'd recommend you to use Marc's

Re: Best approach to handle accented letters

2016-10-28 Thread Chris via Digitalmars-d-learn
On Friday, 28 October 2016 at 13:50:24 UTC, Alfred Newman wrote: On Friday, 28 October 2016 at 11:40:37 UTC, Chris wrote: [...] @Chris As a new guy in the D community, I am not sure, but I think the line below is something like a Python's lambda, right ? auto removed = to!string(str.map!(a

Re: Best approach to handle accented letters

2016-10-28 Thread Alfred Newman via Digitalmars-d-learn
On Friday, 28 October 2016 at 11:40:37 UTC, Chris wrote: On Friday, 28 October 2016 at 11:24:28 UTC, Alfred Newman wrote: Hello, I'm getting some troubles to replace the accented letters in a given string with their unaccented counterparts. Let's say I have the following input string "très é

Re: Best approach to handle accented letters

2016-10-28 Thread Chris via Digitalmars-d-learn
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

Re: Best approach to handle accented letters

2016-10-28 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 28 October 2016 at 11:24:28 UTC, Alfred Newman wrote: Hello, I'm getting some troubles to replace the accented letters in a given string with their unaccented counterparts. Let's say I have the following input string "très élégant" and I need to create a function to return just "t

Re: Best approach to handle accented letters

2016-10-28 Thread Chris via Digitalmars-d-learn
On Friday, 28 October 2016 at 11:24:28 UTC, Alfred Newman wrote: Hello, I'm getting some troubles to replace the accented letters in a given string with their unaccented counterparts. Let's say I have the following input string "très élégant" and I need to create a function to return just "t

Best approach to handle accented letters

2016-10-28 Thread Alfred Newman via Digitalmars-d-learn
Hello, I'm getting some troubles to replace the accented letters in a given string with their unaccented counterparts. Let's say I have the following input string "très élégant" and I need to create a function to return just "tres elegant". Considering we need to take care about unicode char