diff --git a/src/Demo/Hello.cs b/src/Demo/Hello.cs index 95cd9f1..61c152a 100644 --- a/src/Demo/Hello.cs +++ b/src/Demo/Hello.cs @@ -1,3 +1,6 @@ #:property ImplicitUsings=true +#:package Spectre.Console@0.51.* -Console.WriteLine("Hello, World!"); \ No newline at end of file +using Spectre.Console; + +AnsiConsole.MarkupLine(":globe_showing_americas: Hello, World!"); \ No newline at end of file diff --git a/src/SmallSharp/ConsoleEncodingInitializer.cs b/src/SmallSharp/ConsoleEncodingInitializer.cs new file mode 100644 index 0000000..446c74f --- /dev/null +++ b/src/SmallSharp/ConsoleEncodingInitializer.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + +namespace System; + +/// +/// Ensures that when running from Visual Studio on Windows, the console encoding is set to UTF-8 +/// to support full Unicode and emoji output. +/// +class ConsoleEncodingInitializer +{ +#pragma warning disable CA2255 // The 'ModuleInitializer' attribute should not be used in libraries + [ModuleInitializer] +#pragma warning restore CA2255 // The 'ModuleInitializer' attribute should not be used in libraries + public static void Init() + { + +#if DEBUG + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + Console.InputEncoding = Console.OutputEncoding = Encoding.UTF8; +#endif + } +} diff --git a/src/SmallSharp/Sdk.props b/src/SmallSharp/Sdk.props index 1b59562..4545ff2 100644 --- a/src/SmallSharp/Sdk.props +++ b/src/SmallSharp/Sdk.props @@ -25,4 +25,9 @@ + + + + \ No newline at end of file diff --git a/src/SmallSharp/SmallSharp.csproj b/src/SmallSharp/SmallSharp.csproj index d00d143..b63c071 100644 --- a/src/SmallSharp/SmallSharp.csproj +++ b/src/SmallSharp/SmallSharp.csproj @@ -21,6 +21,7 @@ + diff --git a/src/SmallSharp/SmallSharp.targets b/src/SmallSharp/SmallSharp.targets index f49a053..b1781c4 100644 --- a/src/SmallSharp/SmallSharp.targets +++ b/src/SmallSharp/SmallSharp.targets @@ -28,6 +28,7 @@ +