Reputation: 451
I want to take the input in UTF-8 character encoded using Console.ReadLine()
or any other method in C#. In java I have found this
Scanner in = new Scanner(System.in, "utf-8");
I'm getting this output: I0NISMS4QhiSWnSIADCAXg
But the expected output is this type: {"result": 5, "id": 1}
Upvotes: 2
Views: 7972
Reputation: 3735
just set the Console.OutputEncoding
to UTF-8
:
Console.OutputEncoding = System.Text.Encoding.UTF8;
for example :
static void Main(string[] args)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
using (StreamReader reader = new StreamReader("test1.txt",System.Text.Encoding.UTF8))
{
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
Console.ReadLine();
}
AND also configure your console font such this:
Upvotes: 2