I saw similar topics, but could not find a solution. My problem is that I have a .txt file in which the characters are in Bulgarian / which is Cyrillic /, but after trying to read them, there is no success. I tried to read this code:
StreamReader reader = new StreamReader(fileName,Encoding.UTF8);
if (File.Exists(fileName))
{
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
And I also changed the Encoding value to everything possible, as I tried with GetEncoding (1251), which I wrote for the Cyrillic alphabet. And when I save the .txt file, I tried to save it with every different encoding that was there / UNICODE, UTF-8, BigEndianUnicode, ANSI / in every combination with the encoding that I set through the code, but again without success.
Any ideas on how to read Cyrillic characters in the right direction will be appreciated. And here is a sample text for this: "This is a sample text."
Thanks in advance!:)
source
share