Reputation: 128
I m developing a c# hangman game for a competition.
I generate some words that have french characters and my vs2015 is not supporting them. For example when it generates "mûre" word instead of "û" there is displayed a "?".
I tried to go to Tools->Options->International Settings and there to download French language pack. I runned it and nothing happened. My displayed options there are only "English" and "Same as Microsoft Windows". ( I restarted my pc after installation);
Here is my function that generates the word:
private void generateRandomWord_Survival() {
Random rand;
rand = new Random();
if (!playSurvival) return;
StreamReader filereader;
int lineNumber = 0;
filereader = new StreamReader(@"survival_easy.txt");
if (survival_level == "easy") {
filereader = new StreamReader(@"survival_easy.txt");
lineNumber = File.ReadAllLines(@"survival_easy.txt").Length;
} else if (survival_level == "medium") {
filereader = new StreamReader(@"survival_medium.txt");
lineNumber = File.ReadAllLines(@"survival_medium.txt").Length;
} else if (survival_level == "hard") {
filereader = new StreamReader(@"survival_hard.txt");
lineNumber = File.ReadAllLines(@"survival_medium.txt").Length;
}
int line = rand.Next(1, lineNumber);
string text = String.Empty;
for (int i = 1; i <= line; i++) {
text = filereader.ReadLine();
}
filereader.Close();
word = text.ToCharArray();
initLabelSetup();
initLabelSetup();
}
Upvotes: 1
Views: 1291
Reputation: 2431
Try using a different encoding when you read the file.
File.ReadAllLines(@"survival_easy.txt", Encoding.GetEncoding("iso-8859-1"));
Upvotes: 1