Search code examples
c#character-encodingscriptcs

How to achieve correctly encoded output with scriptcs?


I'm trying to write cyrillic symbols to output:

// scr.csx
using System;
Console.WriteLine("asd ПРИВЕТ");

But it is not displayed as expected when I run it:

> scriptcs scr
asd ??????

I've tried to save scr.csx in different encodings, it does not help.


Solution

  • Add this line before outputting:

    Console.OutputEncoding = System.Text.Encoding.UTF8;