Home c# Reading Cyril with C #

Reading Cyril with C #




You need to consider the file in which there are symbols of the Cyril, when displaying all the CLIRIC icons displayed by the question marks.
Here’s how I read the text from the file:

static void main (String [] Args)
      STRING PATH = @ "C: \ Users \ User \ desktop \ Words \ WORXDS.TXT";
      Using (Filestream Fstream = File.openread (Path))
        // Transform the string to bytes
        Byte [] Array = New Byte [Fstream.Length];
        // Read the data
        Fstream.Read (Array, 0, Array.Length);
        // Decoding bytes in the string
        String TextFromFile = System.Text.Encoding.default.getString (Array);
        Console.Writeline ($ "text from file: {TextFromFile}");

Is there a way to correctly select Cyril after reading in the console?

Answer 1, Authority 100%

You need to change the file encoding on UTF-8.

Answer 2, Authority 100%

Use Unicode. If you encode anything other than the English (American) language, then always use unicode.

You, of course, can also use 1251 (ASCII 7-bit, +1 bits for Russian characters), but it is used only in texts in Russian, and in Unicode you can insert any characters in the 1st text.

var text = file.ReadallText ("Path / To / File", Encoding.unicode);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions