Skip to content

'Basic' rendering and no emojis unless Console.OutputEncoding is set to UTF8 #1964

@roy-t

Description

@roy-t

Information

  • OS: Windows 11
  • Version: 25H2
  • Terminal: Powershell 7.5.4 on Windows Terminal 1.23.12811.0
  • Spectre.Console 0.51.1

Describe the bug
I've been playing with Spectre.Console on and off for the last three months and I couldn't figure out why a lot of the features look quite basic compared to the example screenshots. Emojis wont work at all, even though just writing those out with Console.WriteLine works fine.

Today I added the following line at the start of my program:

Console.OutputEncoding = Encoding.UTF8;

And all of a sudden everything works. Is this line missing in the quickstart on https://spectreconsole.net/quick-start? Or is this a bug where Spectre.Console doesn't detect the correct output encoding? I assume setting the output encoding to UTF8 might also cause problems when mixing some strings contain UTF16 characters, as that is the default C# string type.

To Reproduce
Steps to reproduce the behavior.

private static void Main(string[] args)
{
    AnsiConsole.MarkupLine("Hello :globe_showing_europe_africa:!");
}

Will render ??! instead of the globe emojii.

Additional context
This does work:

private static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
AnsiConsole.MarkupLine("Hello :globe_showing_europe_africa:!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions