C#控制台正在输出框字符as''?&quot
我正在在ASCII中制作游戏,以娱乐,我遇到了一个问题,即以我期望的方式打印角色。 它不是正常打印的角色,而是打印出问号。 情况是:
预期结果:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ PacGunMan [_][^][X] ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Main Menu ┃
┃ ━━━━━━━━━━━━━━━━━━━━━ ┃
┃ ┃
┃ [1] Start ┃
┃ [2] Settings ┃
┃ [3] Credits ┃
┃ [4] Exit ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
我实际上得到的:
???????????????????????????????
? PacGunMan [_][^][X] ?
???????????????????????????????
? Main Menu ?
? ????????????????????? ?
? ?
? [1] Start ?
? [2] Settings ?
? [3] Credits ?
? [4] Exit ?
? ?
???????????????????????????????
渲染源代码:
public static void Automatic(List<string> RenderItem) {
Console.WriteLine("Rendering...");
foreach (string Y in RenderItem) { // The variable is named "Y" because Y-Axis
Console.WriteLine(Y);
}
}
I am making a game in ascii for fun and I have an issue where the characters are not printed in the way that i have expected them.
instead of the characters being printed normally, it instead prints out question marks.
here's the situation:
Expected Outcome:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ PacGunMan [_][^][X] ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Main Menu ┃
┃ ━━━━━━━━━━━━━━━━━━━━━ ┃
┃ ┃
┃ [1] Start ┃
┃ [2] Settings ┃
┃ [3] Credits ┃
┃ [4] Exit ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
What I actually got:
???????????????????????????????
? PacGunMan [_][^][X] ?
???????????????????????????????
? Main Menu ?
? ????????????????????? ?
? ?
? [1] Start ?
? [2] Settings ?
? [3] Credits ?
? [4] Exit ?
? ?
???????????????????????????????
Rendering Source Code:
public static void Automatic(List<string> RenderItem) {
Console.WriteLine("Rendering...");
foreach (string Y in RenderItem) { // The variable is named "Y" because Y-Axis
Console.WriteLine(Y);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C#,由于某些原因,在ASCII编码中打印字符。因此,我们需要将编码类型更改为UTF-8。
发生这种情况的原因之一可能是因为字符实际上可能没有以ASCII格式。但是在这种情况下,这是打印错误/问题,而不是字符的问题。
因此,这就是我们可以做到的:
因此,这是渲染源代码的外观:
C#, for some reason, prints characters in ASCII Encoding. So we need to change the encoding type to UTF-8.
One of the reasons why this happens is maybe because the characters may not actually be in an ASCII format. But in this case, it was the printing error/problem and not the characters' problem.
So here's how we can do that:
so here's how the Rendering Source Code should look like: