1

I have utilised the Colorful Console nuget:

<PackageReference Include="Colorful.Console" Version="1.2.15" />

With the intention of printing non-ASCII characters to a console app in Powershell:

using Console = Colorful.Console;
...
Console.Write("•", Color.Gray);

But this does not display anything in powershell or the VSCode Terminal.

Am I missing something or is powershell simply not able to display that character when colorised?

mklement0
  • 382,024
  • 64
  • 607
  • 775
Matt W
  • 11,753
  • 25
  • 118
  • 215

1 Answers1

0

For full Unicode support on Windows, make sure your console's code page is 65001 (UTF-8) before calling your program:

  • from cmd.exe:
    • chcp 65001
  • from PowerShell:
    • $OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new()

Unless you happen to have used the still-in-beta Windows 10 feature that activates system-wide UTF-8 support (see this answer), your default OEM (console) code page is a fixed, single-byte encoding such as 437 on US-English systems, which is limited to 256 characters and therefore cannot represent Unicode characters such as (BULLET, U+2022).

Seemingly, with code page 437 in effect, degrades to an invisible ASCII-range control character (ALERT, U+0007).

Note:

  • This behavior is not specific to the Colorful.Console package; it equally applies to the built-in Console.WriteLine().

  • Changing a console's code page can affect other programs, so you may have to restore the original one.

mklement0
  • 382,024
  • 64
  • 607
  • 775