简体   繁体   English

ASCII字符

[英]ASCII characters

I'm doing a homework assignment in which I need to print out to the console and a text file the numbers 0-255 along with the Hex and Ascii which goes along with them. 我正在做作业,其中需要打印到控制台和文本文件,编号为0-255,以及与之配套的Hex和Ascii。

The main focus of the assignment is to learn about formatting and file handling. 作业的主要重点是学习格式和文件处理。

I've figured out all the nice formatting by using widths and I can print things out to the file no problem. 我已经通过使用宽度找出了所有不错的格式,并且可以将它们打印到文件中没有问题。

I'm using %d %X %c for my printf() . 我正在将%d %X %c用于我的printf()

My pet peeve is that ASCII 11, 12 and 13(???) are something like tab, lf and some other non-image char. 我的烦恼是ASCII 11、12和13(???)类似于tab,lf和其他一些非图像字符。

This totally screws with those two rows and I'm a wee bit anal about stuff like this. 这与这两行完全搞砸了,我对这样的事情有点厌烦。

Is there a fast and easy way to get something else to show up that won't screw with my columns and rows or do I need to put in if -statements and filter these guys out myself? 是否有一个快速简便的方法来获得别的东西展现出来,将不符合我的列和行螺钉或做我需要把if -statements和这些家伙过滤掉自己?

You'll need to filter out things you don't want to print yourself. 您需要过滤掉不想打印的内容。

To help with that, look into the isgraph and the other is* functions. 为了解决这个问题,请查看isgraph和另一个is*函数。 They should help you along pretty well. 他们应该很好地帮助您。

Most of the bottom characters are not printable. 大多数底部字符不可打印。 You'll have to print something else. 您将不得不打印其他内容。 The best thing I can think is create an array of strings for lowest 32 chars, which are problematic and print from the lowest 32 from there while you use the normal print for the others (but yes, you need some kind of if). 我能想到的最好的办法是为最低的32个字符创建一个字符串数组,这是有问题的,并且从那里的最低32个字符开始打印,而对其他字符使用常规打印(但是,您需要某种if)。

These characters are called "Control Characters" and will be difficult to print if you only assign one single character space for them. 这些字符称为“控制字符” ,如果仅为其分配一个字符空间,则将很难打印。

You should be able to catch all of these with a call to iscntrl() and print something more convenient in their place. 您应该能够通过调用iscntrl()捕获所有这些内容,并在它们的位置打印一些更方便的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM