Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong .NET Core console output encoding on Windows #20157

Closed
Maxim-Kornilov opened this issue Feb 9, 2017 · 4 comments
Closed

Wrong .NET Core console output encoding on Windows #20157

Maxim-Kornilov opened this issue Feb 9, 2017 · 4 comments

Comments

@Maxim-Kornilov
Copy link

Command prompt on my computer have a 866 (OEM - Russian) encoding, but .NET Core app says it is Unicode (UTF-8).

Source code:

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string helloWorld = "Здравствуй, Мир!";
            Console.WriteLine(Console.OutputEncoding.EncodingName);
            Console.WriteLine(helloWorld);

            Console.OutputEncoding = Console.OutputEncoding;
            Console.WriteLine(Console.OutputEncoding.EncodingName);
            Console.WriteLine(helloWorld);
        }
    }
}

Console output:

D:\ConsoleApp1>dotnet run
Unicode (UTF-8)
╨Ч╨┤╤А╨░╨▓╤Б╤В╨▓╤Г╨╣, ╨Ь╨╕╤А!
Unicode (UTF-8)
Здравствуй, Мир!

D:\ConsoleApp1>dotnet --info
.NET Command Line Tools (1.0.0-rc4-004771)

Product Information:
 Version:            1.0.0-rc4-004771
 Commit SHA-1 hash:  4228198f0e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-rc4-004771
@ianhays
Copy link
Contributor

ianhays commented Feb 9, 2017

Heya @Maxim-Kornilov, this is a duplicate of https://github.com/dotnet/corefx/issues/10054 and is expected behavior. Please comment over there after reading the comments if you have any further concerns :)

@ianhays ianhays closed this as completed Feb 9, 2017
@Maxim-Kornilov
Copy link
Author

OK. But it is still looks like a bug even if it is an expected behavior. It is working as expected on a full .NET Framework.

@JohnRusk
Copy link

JohnRusk commented Jul 2, 2017

@ianhays I'm having the same problem. How can there be no bug here? I can reproduce the following sequence of events:

  1. Start app
  2. Read Console.OutputEncoding. It says its UTF-8
  3. Display output. It does not come out in UTF-8, even though that was reported as the current encoding.
  4. Set the encoding to UTF-8. (I.e. set it to its existing value).
  5. Display output again. Now it does come out in UTF-8.

If setting a property to its existing value changes behavior, how can that not be a bug? (In this the case, the bug is present before the "set", since at that point in the process the getting is returning a value which clearly is not actually being used).

@ianhays
Copy link
Contributor

ianhays commented Jul 5, 2017

Hey @JohnRusk, please comment on #17849 instead, as this issue is a duplicate and the discussion is focused in #17849.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants