0

I've made a Hangman Game in C# using Visual Studio Windows Forms for class project. It's all working and delivered so no, I don't want you made the game for me, don't worry. The help is for improving it out of class tasks. I'll explain myself: game is made in spanish, it's for guess an animal and I've used animals without special characters, but there are others like "águila" (eagle) or "murciélago" (bat) that has special characters and I want to include those so when you enter a letter like "a" be accepted as "á" too if it's in the secret word, and the correct letter be revealed with the correct character, be special or not, this is: for "águila" you input an 'a' and the reveal will be like "á _ _ _ _ a".

The input textbox accepts only a letter. The randomized animal is an array of textboxes, one per letter. Thanks so much in advance!

I hope I explained myself. And sorry for my english (it's not my first language, even it's not the second neither). If you need to see specific part of the code I'll gladly share it (I am not sharing whole code to avoid people that is studying too get the whole program made XD). Thanks so much in advance.

Dhanen
  • 1
  • 2
  • 2
    Those are not special chars – Leandro Bardelli Dec 04 '21 at 13:43
  • 3
    Does this answer your question: [How do I remove diacritics (accents) from a string in .NET?](https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net) – Olivier Jacot-Descombes Dec 04 '21 at 13:53
  • Leandro: Well, thanks for the info, but u didn't answered to my question, and u said aren't special chars, but not what really are so I could change the title, so... Oliver: No, I don't want to convert or remove diacritics, I want the game accepts a as "á" or "a", revealing the letter if well guessed accepting it as correct, and appearing correctly written in the revealed letters of word as the example I put, word: "águila", letter input: "a", revealed word: "á_ _ _ _ a". Thanks anyway. – Dhanen Dec 04 '21 at 16:29
  • Remove them for the comparison only. Something like `if (RemoveDiacritics(word).StartsWith(RemoveDiacritics(input))` to test whether the user input matches the beginning of a given word by ignoring diacritics. – Olivier Jacot-Descombes Dec 04 '21 at 16:55
  • Didn't knew of that function. I'll try and share results. Thanks so much, Oliver. – Dhanen Dec 04 '21 at 19:31
  • I don't know your logic, but there is also a `string.Contains` method that may better fit in your case. – Olivier Jacot-Descombes Dec 06 '21 at 11:26
  • The fact is that "á" and "a" are different characters. The "Contains" method is what I am using right now for words without any marks, but if the user inputs "a" and there is an "á", it won't be revealed but only all the "a" 's. That's what I need the revealed letters accepts in the input letters with and without accentuation marks. – Dhanen Dec 07 '21 at 12:43

0 Answers0