admin管理员组文章数量:1277346
After publishing a console app (using dotnet publish
), the console app does not display the emojis properly in Windows Terminal.
Interestingly, if I just use dotnet run
, the emojis appear properly in Windows Terminal.
I published the console app using --no-self-contained
and without it. Both result with the emojis not showing properly.
This is happening on both Windows 10 version 22H2 and Windows 11 version 23H2.
I'm using .NET 9.0.200.
Sample code:
const string CHECKMARK1 = "✅";
const string CHECKMARK2 = "\u2705";
Console.WriteLine(CHECKMARK1);
Console.WriteLine(CHECKMARK2);
Console.WriteLine("✅");
Console.WriteLine("\u2705");
Output using dotnet run
in Windows Terminal:
✅
✅
✅
✅
EXE output after using dotnet publish
in Windows Terminal:
?
?
?
?
Also, for thoroughness, here are the commands I used for publishing:
dotnet.exe publish "c:\path\to\emoji.csproj" --runtime "win-x64" --no-self-contained /p:PublishSingleFile=true
dotnet.exe publish "c:\path\to\emoji.csproj" --runtime "win-x64" /p:PublishSingleFile=true
I would appreciate any insight into why this is happening.
After publishing a console app (using dotnet publish
), the console app does not display the emojis properly in Windows Terminal.
Interestingly, if I just use dotnet run
, the emojis appear properly in Windows Terminal.
I published the console app using --no-self-contained
and without it. Both result with the emojis not showing properly.
This is happening on both Windows 10 version 22H2 and Windows 11 version 23H2.
I'm using .NET 9.0.200.
Sample code:
const string CHECKMARK1 = "✅";
const string CHECKMARK2 = "\u2705";
Console.WriteLine(CHECKMARK1);
Console.WriteLine(CHECKMARK2);
Console.WriteLine("✅");
Console.WriteLine("\u2705");
Output using dotnet run
in Windows Terminal:
✅
✅
✅
✅
EXE output after using dotnet publish
in Windows Terminal:
?
?
?
?
Also, for thoroughness, here are the commands I used for publishing:
dotnet.exe publish "c:\path\to\emoji.csproj" --runtime "win-x64" --no-self-contained /p:PublishSingleFile=true
dotnet.exe publish "c:\path\to\emoji.csproj" --runtime "win-x64" /p:PublishSingleFile=true
I would appreciate any insight into why this is happening.
Share Improve this question edited Feb 24 at 16:12 marc_s 755k184 gold badges1.4k silver badges1.5k bronze badges asked Feb 24 at 14:40 howdoicodehowdoicode 99311 silver badges20 bronze badges 2- It will also show question marks when ran in Visual Studio. i.sstatic/fzNKN3Y6.png – gunr2171 Commented Feb 24 at 14:50
- @gunr2171 — Sure. Did you see my answer? It works the same way when executed in Visual Studio. – Sergey A Kryukov Commented Feb 25 at 0:22
1 Answer
Reset to default 5Before the first System.Console
output call, you have to execute:
System.Console.OutputEncoding = System.Text.Encoding.UTF8;
In contrast to some other Console
calls, this property assignment can throw an exception if the entry assembly has a wrong OutputType
. It should be <OutputType>Exe</OutputType>
.
本文标签: cEmojis not displaying properly after publishing exe in NET 9Stack Overflow
版权声明:本文标题:c# - Emojis not displaying properly after publishing exe in .NET 9 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741263031a2367974.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论