在 C# 中打印前 30 个 ASCII 字符会在一个框中显示结果
尝试在文本框中打印前 30 个 Ascii 字符,结果会生成一个框符号。任何建议请。
Trying to print first 30 Ascii characters in a text box and it results in a box symbol. Any suggestions pls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些是
控制字符
,您无法全部打印它们。阅读 wiki (ASCII)These are
control characters
and you can't print them all. Read wiki (ASCII)前 32 个 ASCII 字符是不可打印的控制字符。
字体中没有字形的字符通常呈现为方框。
The first 32 ASCII characters are non-printable control characters.
Characters that do not have a glyph in a font are usually rendered as a box.
您想要打印的内容已被“重新映射”以实现“历史兼容性”到其他代码点:请阅读此处 http:// /en.wikipedia.org/wiki/Code_page_437
字体相当重要!并非所有字体都有这些“dingbats”。
Lucida Console
可以。您应该得到以下输出:
☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼
请注意,我正在替换带有
Space
的NUL
(代码\0
带有\x20
),因为文本框对NUL
ls 的容忍度不太高。我要补充一点,我无法找到有关命令提示符控制台对低 ASCII 字符进行“自动”重新映射的任何信息。它没有太多记录。 (如果您尝试执行
echo ^E
(使用 ^E = Ctrl+E)并按 Enter 键,您将得到♣
,但这里完成了重新映射,因为我的控制台使用的是 Lucida Console,代码 5 处没有♣
。)What you want to print has been "remapped" for "historical compatibility" to other code points: read here http://en.wikipedia.org/wiki/Code_page_437
The font is quite important! Not all the fonts have these "dingbats".
Lucida Console
does.You should get this output:
☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼
Note that I'm replacing the
NUL
with aSpace
(the code\0
with\x20
) because the textbox isn't very forgiving withNUL
ls.I'll add that I wasn't able to find any information on the "automatic" remapping the Command Prompt console does for low ascii characters. It isn't documented very much. (if you try to do
echo ^E
(with ^E = Ctrl+E) and press enter, you will get♣
, but there is a remapping done here, because my console is using Lucida Console that at code 5 doesn't have a♣
.)