Re: Compare string with German umlauts

2020-05-19 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 18 May 2020 at 14:28:33 UTC, Steven Schveighoffer wrote: What you need is to normalize the data for comparison: https://dlang.org/phobos/std_uni.html#normalize For more reference: https://en.wikipedia.org/wiki/Combining_character -Steve I checked it again but could not

Re: Compare string with German umlauts

2020-05-19 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 18 May 2020 at 14:28:33 UTC, Steven Schveighoffer wrote: On 5/18/20 9:44 AM, Martin Tschierschke wrote: [...] using == on strings is going to compare the exact bits for equality. In unicode, things can be encoded differently to make the same grapheme. For example, ö is a code

Re: Compare string with German umlauts

2020-05-19 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 18 May 2020 at 14:22:31 UTC, WebFreak001 wrote: [...] It solved the problem, but what is the right way to use umlauts (encode them) inside the program? Your code should have already worked like that, assuming your input file is a UTF-8 file. Check with an editor like Notepad++ or

Re: Compare string with German umlauts

2020-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/20 9:44 AM, Martin Tschierschke wrote: Hi, I have to find a certain line in a file, with a text containing umlauts. How do you do this? The following was not working: foreach(i,line; file){  if(line=="My text with ö oe, ä ae or ü"){    writeln("found it at line",i)  } } I ended up

Re: Compare string with German umlauts

2020-05-18 Thread WebFreak001 via Digitalmars-d-learn
On Monday, 18 May 2020 at 13:44:15 UTC, Martin Tschierschke wrote: Hi, I have to find a certain line in a file, with a text containing umlauts. How do you do this? The following was not working: foreach(i,line; file){ if(line=="My text with ö oe, ä ae or ü"){ writeln("found it at

Compare string with German umlauts

2020-05-18 Thread Martin Tschierschke via Digitalmars-d-learn
Hi, I have to find a certain line in a file, with a text containing umlauts. How do you do this? The following was not working: foreach(i,line; file){ if(line=="My text with ö oe, ä ae or ü"){ writeln("found it at line",i) } } I ended up using line.canFind("with part of the text