0

I have found a way how to display the list without diacritic but how to display it with diacritic ? Here I am checking if the value is in the list twice, if it is then I need to display the one with diacritic but how do I check for diacritic?

{

    var fields = new List<Field>()
    {
        new Field{ Value ="Kateřina Kučerová", IdentityDocumentFieldType = IdentityDocumentFieldType.unknown},
        new Field{ Value = "Katerina Kucerova", IdentityDocumentFieldType = IdentityDocumentFieldType.Document},
    };


    foreach (var field in fields)
    {
        var value = field.Value;

       //Console.WriteLine(StringExtenstion.RemoveDiacritics(value));

        var exists = fields.Any(r => r.Desc == field.Desc);
        if (!exists)
        {
            Console.WriteLine(field.Value);
        }
        else
        {
            Console.WriteLine(field.Value);
        }

    }}
Tes Nov
  • 83
  • 8
  • 1
    A diacritic is a different character than one without a diacritic. So you would need to map the diacritic character to a non diacritic. You would need a object that you can manually create that maps one character to another character and then use to replace the characters. – jdweng Dec 18 '20 at 14:37
  • so I have to go char by char and store the non diacritic to different object? I am sorry I don't quite get it – Tes Nov Dec 18 '20 at 14:43
  • These two topics may be the solution to your question: [check diacritics](https://stackoverflow.com/questions/9349608/how-to-check-if-unicode-character-has-diacritics-in-net) or [remove diacritics](https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net) – Volkan Barbaros Gurcan Dec 18 '20 at 14:44
  • You need ot replace one character with a different character. – jdweng Dec 18 '20 at 14:54
  • I don't need to replace I just need to check – Tes Nov Dec 18 '20 at 15:05

1 Answers1

1
string input =@"Kateřina Kučerová";
            var samo = "řčěáíéě";
           
            foreach (char c in samo)
            {
                if(input.Contains(c))
                    Console.WriteLine("ok");
              
            }

This is what I needed

Tes Nov
  • 83
  • 8