-2

I need to compare two strings in a word document I work it out for alphabetic and numeric values but it is not able to compare a string which contains some special characters like Máceres-Cartínez(á,í,ä) my code did not consider this occurrence as a string. StreamWriter(fsf);

    swt.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");

    swf.WriteLine("Startred on :" + DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss") + "\n");


    foreach (string strPara in strParaValue)

      {
          string[] strAuthorsPart = strPara.Split('.');

          string[] strAuthorslist = strAuthorsPart[0].Split(',');

          string[] strAuthor = strAuthorslist[0].Split(' ');

          if (strSplitValue[0].Contains(strAuthor[0].Trim()))

         {

             swt.WriteLine(strAuthor[0] + "\t");

         }

              else

         {

             swf.WriteLine(strAuthor[0] + "\t");

         }

              swt.WriteLine("\r\n");

              swf.Flush();

          }

Please let me suggest on this regards.

DeeGo

DeeGo
  • 17
  • 5
  • 3
    -1. Please review your code sample and remove commented out stuff unrelated to the question and mark a place that is causeing you problems. – Alexei Levenkov Apr 06 '12 at 05:08
  • This is my function Here two string compare with other and produce the output – DeeGo Apr 06 '12 at 05:17

1 Answers1

2

If I understood your question correctly, you want to ignore diacritics when comparing two strings, i.e. "Maceres" should match "Máceres".

If that is correct, the simplest solution is to remove diacritics from both strings and then compare them. The following question contains suggestions on how to do that:

Community
  • 1
  • 1
Heinzi
  • 167,459
  • 57
  • 363
  • 519